Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import pyodbc
  2. import pandas as pd
  3.  
  4. cnxn = pyodbc.connect(driver='{SQL Server Native Client 10.0}',
  5. host=server,database=dbname,
  6. trusted_connection=tcon,
  7. user=uname,password=pword)
  8.  
  9. cursor = cnxn.cursor()
  10.  
  11. df.head()
  12. Date_1 Date_2
  13. 1 2015-07-01 10:53:16 2015-07-01 00:13:09
  14. 2 2015-07-03 10:31:16 2015-07-01 16:39:40
  15. 3 2015-06-26 14:39:19 2015-06-24 13:56:17
  16.  
  17. for index, row in df.iterrows():
  18. cursor.execute("""
  19. INSERT INTO Table(
  20. Date1,Date2)"""
  21. """VALUES (?,?)""",
  22. row['Date1'],row['Date2'])
  23.  
  24. cnxn.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement