Richard Tolar
unread,Nov 11, 2010, 12:07:19 PM11/11/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pyodbc
Are some commands not parameterizable, such as Create Database?
SQL Server 2008
current version of pyodbc for python 2.6
script:
------------------
import pyodbc
connection = pyodbc.connect('DRIVER={SQL
Server};SERVER=AAA;UID=BBB;PWD=CCC',autocommit=True)
cursor = connection.cursor()
cursor.execute('create database ?', 'richard_test_6')
-----------------
Fails with
Traceback (most recent call last):
File "C:\dev\atsm_31\trunk\db\foo.py", line 5, in <module>
cursor.execute('create database ?', 'richard_test_6')
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL
Server Driver][
SQL Server]Incorrect syntax near '@P1'. (102) (SQLExecDirectW);
[42000] [Microso
ft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be
prepared. (8180)")
If you replace the last line with:
#cursor.execute('create database richard_test_6')
it works.