Guest User

Untitled

a guest
Jan 8th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. from pymssql import connect # @UnresolvedImport
  2.  
  3. conn = connect(host="127.0.0.1", user="DataClient", password="test",
  4. database="TimeSeries")
  5. cursor = conn.cursor()
  6. cursor.execute("exec getResearchSalesAndRepurchaseByYear %s, %d", ('F000000I1F',2011))
  7. rows = cursor.fetchall()
  8.  
  9. for row in rows:
  10. print row[0]
  11. print row[1]
  12.  
  13. # cursor.execute("""
  14. # IF OBJECT_ID('persons', 'U') IS NOT NULL
  15. # DROP TABLE persons
  16. # CREATE TABLE persons (
  17. # id INT NOT NULL,
  18. # name VARCHAR(100),
  19. # salesrep VARCHAR(100),
  20. # PRIMARY KEY(id)
  21. # )
  22. # """)
  23.  
  24. # cursor.executemany(
  25. # "INSERT INTO persons VALUES (%d, %s, %s)",
  26. # [(1, 'John Smith', 'John Doe'),
  27. # (2, 'Jane Doe', 'Joe Dog'),
  28. # (3, 'Mike T.', 'Sarah H.')])
  29. # # you must call commit() to persist your data if you don't set autocommit to True
  30. # conn.commit()
  31.  
  32. # cursor.execute('SELECT * FROM persons WHERE salesrep=%s', 'John Doe')
  33. # row = cursor.fetchone()
  34. # while row:
  35. # print("ID=%d, Name=%s" % (row[0], row[1]))
  36. # row = cursor.fetchone()
  37.  
  38. conn.close()
Add Comment
Please, Sign In to add comment