Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pip install pymysql
- from __future__ import print_function
- import pymysql
- import warnings
- DB_HOST = 'xxx.xxx.xxx.xxx'
- DB_PORT = 9999
- DB_USER = 'username'
- DB_PASS = 'password'
- conn = pymysql.connect(host=DB_HOST, port=DB_PORT,
- user=DB_USER, passwd=DB_PASS,
- db='mobiledoc', local_infile=1)
- cursor = conn.cursor(pymysql.cursors.SSDictCursor)
- warnings.simplefilter('ignore', pymysql.Warning)
- warnings.simplefilter('ignore', UserWarning)
- cursor.execute("select count(1) count from users")
- print(cursor.fetchone()['count'], "users")
- cursor.execute("select count(1) count from enc")
- print(cursor.fetchone()['count'], "encounters")
- cursor.execute("insert into document (customName) values('pt_test_2349234');")
- cursor.execute("select count(1) count from document where customName='pt_test_2349234';")
- print(cursor.fetchone()['count'], "test document record found after insert")
- cursor.execute("delete from document where customName='pt_test_2349234';")
- cursor.execute("select count(1) count from document where customName='pt_test_2349234';")
- print(cursor.fetchone()['count'], "test document record found after delete")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement