Advertisement
Guest User

Untitled

a guest
Aug 27th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import pymssql
  2. import pandas as pd
  3. conn = pymssql.connect(server="localhost",
  4. user="SA",password="Tammar11", port=1433)
  5. cursor = conn.cursor()
  6.  
  7. cursor.execute('use TestDB')
  8.  
  9. #cursor.execute("drop test_table")
  10.  
  11. cursor.execute("""
  12. CREATE TABLE test_table (ddd INT)""")
  13.  
  14. stmt = "SELECT * from test_table"
  15. df = pd.read_sql(stmt,conn)
  16. print df.shape
  17.  
  18. for x in range(1000):
  19. cursor.execute("insert into test_table values("+str(x)+")")
  20.  
  21. stmt = "SELECT * from test_table"
  22. df = pd.read_sql(stmt,conn)
  23. df.shape
  24.  
  25. import pymssql
  26. import pandas as pd
  27. conn = pymssql.connect(server="localhost",
  28. user="SA",password="Tammar11", port=1433)
  29. cursor = conn.cursor()
  30.  
  31. cursor.execute('use TestDB')
  32.  
  33. stmt = "SELECT * from test_table"
  34. df = pd.read_sql(stmt,conn)
  35. df.shape
  36.  
  37. DatabaseError: Execution failed on sql 'SELECT * from test_table':
  38. (208, "Invalid object name 'test_table'.DB-Lib error message 20018,
  39. severity 16:nGeneral SQL Server error: Check messages from the SQL
  40. Servern")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement