I have the following time-series data with two value columns.

(t: time, v1: time-series values 1, v2: time-series values 2)

 t | v1 | v2 
---+----+----
 1 |  1 |  0
 2 |  2 |  2
 3 |  3 |  4
 4 |  3 |  6
 5 |  3 |  6
 6 |  4 |  6
 7 |  5 |  8
(7 rows)

I am trying to discover (or approximate) the correlation between the $v1$ and $v2$, and use that approximation for the next step predictions.

Please note, the most obvious correlation is $v2(t)=2.v1(t-1)$.

My question is, what are the algorithms to employ for such approximations and are there any open source implementations of those algorithms for SQL/python/javascript?