From 0d07fb460fa9f16e1c9c917252337b4a73216bb1 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Thu, 8 Oct 2015 00:27:29 +0800 Subject: [PATCH] mssql --- vn.data/test_pymssql.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 vn.data/test_pymssql.py diff --git a/vn.data/test_pymssql.py b/vn.data/test_pymssql.py new file mode 100644 index 00000000..6eac6fd7 --- /dev/null +++ b/vn.data/test_pymssql.py @@ -0,0 +1,16 @@ +import pymssql +conn = pymssql.connect(server='stock.database.windows.net', port='1433',user='sqladmin@stock', password='7uhb*IJN', database='StockCn', charset="UTF-8", azure=True) +cur = conn.cursor() +cur.execute('CREATE TABLE persons(id INT, name VARCHAR(100))') +cur.executemany("INSERT INTO persons VALUES(%d, %s)", \ + [ (1, 'John Doe'), (2, 'Jane Doe') ]) +conn.commit() + +cur.execute('SELECT * FROM persons WHERE salesrep=%s', 'John Doe') +row = cur.fetchone() +while row: + print "ID=%d, Name=%s" % (row[0], row[1]) + row = cur.fetchone() + +conn.close() +