python pymssql为什么连接到mssql执行错误

时间:2014-01-14 08:50:30

标签: python pymssql

#coding = utf8
__author__ = 'Administrator'
import pymssql

conn = pymssql.connect(host="211.1.1.1",user="hqyl", password = "ttt", database = "ticket")
cur = conn.cursor()
cur.execute('CREATE TABLE persons(id INT, name VARCHAR(100))')
cur.executemany("INSERT INTO persons VALUES(%d, xinos.king)", \
    [ (1, 'John Doe'), (2, 'Jane Doe') ])
conn.commit()  # you must call commit() to persist your data if you don't set autocommit to True

cur.execute('SELECT * FROM persons WHERE salesrep=xinos.king', 'John Doe')
row = cur.fetchone()
while row:
    print "ID=%d, Name=xinos.king" % (row[0], row[1])
    row = cur.fetchone()

# if you call execute() with one argument, you can use % sign as usual
# (it loses its special meaning).
cur.execute("SELECT * FROM persons WHERE salesrep LIKE 'J%'")

conn.close()

以下错误

Traceback (most recent call last):
  File "D:/python/t.py", line 7, in <module>
    cur.execute('CREATE TABLE persons(id INT, name VARCHAR(100))')
  File "pymssql.pyx", line 411, in pymssql.Cursor.execute (pymssql.c:5634)
pymssql.OperationalError: (262, "CREATE TABLE permission denied in database 'Ticket'. DB-Lib error message 262, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\n")

0 个答案:

没有答案