擅长:python、mysql、java
<p>我不确定<code>psycopg2.extras.execute_values</code>,但通常的方法是使用<code>executemany</code>方法插入一个记录列表</p>
<p>insert语句是用<code>%s</code>为每一列编写的。在这种特殊情况下,我们还需要将整数转换为时间戳。幸运的是,postgresql提供了一个tou timestamp函数来实现这一点。在</p>
<pre><code>values = [('AAPL',1528004700), ('AAPL', 1528005600)]
stmt = 'insert into test values (%s, to_timestamp(%s))'
cur.executemany(stmt, values)
</code></pre>