Is it possible to use the Redshift function GETDATE() along with psycopg2.extras.execute_values when inserting many rows?
df = pd.DataFrame(data={ 'ExampleID' : list(range(1,6)), 'NumericField' : list(range(44,49)), 'UpdateTime' : list('GETDATE()' for i in range(5)) }) conn = psycopg2.connect(dbname=database, host=host, port=5439, user=username, password=password) cursor = conn.cursor() v = df.to_records(index=False).tolist() q = sql.SQL('INSERT INTO tblexample (ExampleID, NumericField, UpdateTime) VALUES %s') execute_values(cursor, q.as_string(cursor), v) conn.commit() Unfortunately, this raises an exception: psycopg2.DataError: invalid input syntax for type timestamp: "GETDATE()"
没有评论:
发表评论