Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id Date Col_1 Col_2 Col_3
- 26 2012-10-18 X 25.7 True
- 42 2012-10-19 Y -12.4 False
- 63 2012-10-20 Z 5.73 True
- In [437]: data.to_sql('data', engine)
- In [438]: data.to_sql('data_chunked', engine, chunksize=1000)
- for row in data.iterrows():
- import psycopg2
- # Fill in the blanks for the conn object
- conn = psycopg2.connect(user = 'user',
- password = 'password',
- host = 'host',
- dbname = 'db',
- port = 666)
- cursor = conn.cursor()
- args_str = b','.join(cursor.mogrify("(%s,%s,...)", x) for x in tuple(map(tuple,np_data)))
- cursor.execute("insert into table (a,b,...) VALUES "+args_str.decode("utf-8"))
- cursor.close()
- flexprobi_conn.commit()
- flexprobi_conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement