Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyodbc
- import pandas as pd
- cnxn = pyodbc.connect(driver='{SQL Server Native Client 10.0}',
- host=server,database=dbname,
- trusted_connection=tcon,
- user=uname,password=pword)
- cursor = cnxn.cursor()
- df.head()
- Date_1 Date_2
- 1 2015-07-01 10:53:16 2015-07-01 00:13:09
- 2 2015-07-03 10:31:16 2015-07-01 16:39:40
- 3 2015-06-26 14:39:19 2015-06-24 13:56:17
- for index, row in df.iterrows():
- cursor.execute("""
- INSERT INTO Table(
- Date1,Date2)"""
- """VALUES (?,?)""",
- row['Date1'],row['Date2'])
- cnxn.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement