forked from NabilSilva/code.fun.do
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulaterAzure.py
29 lines (27 loc) · 883 Bytes
/
populaterAzure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pymssql
import csv
conn = pymssql.connect(server='tia33kx9ix.database.windows.net', user='the_force@tia33kx9ix', password='abc123!@#', database='students')
cursor = conn.cursor()
csvfile1 = open('./thisIsIt.csv', 'rb')
reader = csv.reader(csvfile1, delimiter=',', quotechar='|')
result = []
x = []
for row in reader:
try:
result = tuple(row)
cursor.execute(
"INSERT INTO [codefundoforce].[TestCode] VALUES (%s, %s, %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
result)
except:
pass
# you must call commit() to persist your data if you don't set autocommit to True
conn.commit()
"""
try:
row = cursor.fetchall()
while row:
print row[0] + " " + str(row[1]) + " " + str(row[2])
row = cursor.fetchone()
except:
print "Exception occured"
"""