Advertisement
Guest User

Untitled

a guest
Dec 27th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. # pip install pymysql
  2.  
  3. from __future__ import print_function
  4.  
  5. import pymysql
  6. import warnings
  7.  
  8.  
  9. DB_HOST = 'xxx.xxx.xxx.xxx'
  10. DB_PORT = 9999
  11. DB_USER = 'username'
  12. DB_PASS = 'password'
  13.  
  14. conn = pymysql.connect(host=DB_HOST, port=DB_PORT,
  15. user=DB_USER, passwd=DB_PASS,
  16. db='mobiledoc', local_infile=1)
  17. cursor = conn.cursor(pymysql.cursors.SSDictCursor)
  18.  
  19. warnings.simplefilter('ignore', pymysql.Warning)
  20. warnings.simplefilter('ignore', UserWarning)
  21.  
  22.  
  23. cursor.execute("select count(1) count from users")
  24. print(cursor.fetchone()['count'], "users")
  25.  
  26. cursor.execute("select count(1) count from enc")
  27. print(cursor.fetchone()['count'], "encounters")
  28.  
  29. cursor.execute("insert into document (customName) values('pt_test_2349234');")
  30.  
  31. cursor.execute("select count(1) count from document where customName='pt_test_2349234';")
  32. print(cursor.fetchone()['count'], "test document record found after insert")
  33.  
  34. cursor.execute("delete from document where customName='pt_test_2349234';")
  35.  
  36. cursor.execute("select count(1) count from document where customName='pt_test_2349234';")
  37. print(cursor.fetchone()['count'], "test document record found after delete")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement