Created
January 8, 2019 02:42
-
-
Save Xifeng2009/38ae57ed4b3bdb28dd36deab51dac7e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymssql import connect # @UnresolvedImport | |
conn = connect(host="127.0.0.1", user="DataClient", password="test", | |
database="TimeSeries") | |
cursor = conn.cursor() | |
cursor.execute("exec getResearchSalesAndRepurchaseByYear %s, %d", ('F000000I1F',2011)) | |
rows = cursor.fetchall() | |
for row in rows: | |
print row[0] | |
print row[1] | |
# cursor.execute(""" | |
# IF OBJECT_ID('persons', 'U') IS NOT NULL | |
# DROP TABLE persons | |
# CREATE TABLE persons ( | |
# id INT NOT NULL, | |
# name VARCHAR(100), | |
# salesrep VARCHAR(100), | |
# PRIMARY KEY(id) | |
# ) | |
# """) | |
# cursor.executemany( | |
# "INSERT INTO persons VALUES (%d, %s, %s)", | |
# [(1, 'John Smith', 'John Doe'), | |
# (2, 'Jane Doe', 'Joe Dog'), | |
# (3, 'Mike T.', 'Sarah H.')]) | |
# # you must call commit() to persist your data if you don't set autocommit to True | |
# conn.commit() | |
# cursor.execute('SELECT * FROM persons WHERE salesrep=%s', 'John Doe') | |
# row = cursor.fetchone() | |
# while row: | |
# print("ID=%d, Name=%s" % (row[0], row[1])) | |
# row = cursor.fetchone() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment