chornbeak / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

commit() error on MS SQL2008 and pyodbc for python 3 #308

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I try execute T-SQL query in two cases (i use Win7, python 3.2, MS SQL Server 
express 2008,pyodbc for python 3.2):

-case 1:

using MS SQL Server Management Studio i try to execute query:

USE master;CREATE DATABASE Sales ON (NAME = Sales_dat,FILENAME = 
'C:\saledat.mdf',        SIZE = 10,    MAXSIZE = 50,    FILEGROWTH = 5 ) LOG ON 
( NAME = Sales_log,    FILENAME = 'C:\salelog.ldf',    SIZE = 5MB,    MAXSIZE = 
25MB, FILEGROWTH = 5MB );

it return successful result

-case 2:

import pyodbc
cxnn=pyodbc.connect('DSN=SERVER;UID=sa;PWD=password')
cur=cxnn.cursor()
cur.execute("USE master;CREATE DATABASE Sales ON (NAME = Sales_dat,FILENAME = 
'C:\saledat.mdf',    SIZE = 10,    MAXSIZE = 50,    FILEGROWTH = 5 ) LOG ON ( 
NAME = Sales_log,    FILENAME = 'C:\salelog.ldf',    SIZE = 5MB,    MAXSIZE = 
25MB, FILEGROWTH = 5MB );")
cxnn.commit()

but after running code i receive error

 pyodbc.Error: ('HY000', 'The driver did not supply an error!')

If i run the code without

cxnn.commit()

i have receive no error.
If i use autocommit, i have receive no error too:

cxnn=pyodbc.connect('DSN=SERVER;UID=sa;PWD=password', autocommit=True)
cur=cxnn.cursor()
cur.execute("USE master;CREATE DATABASE Sales ON (NAME=Sales_dat, 
FILENAME='C:\\saledat.mdf', SIZE=10, MAXSIZE=50, FILEGROWTH=5) LOG ON 
(NAME=Sales_log, FILENAME='C:\\salelog.ldf', SIZE=5MB, MAXSIZE=25MB, 
FILEGROWTH=5MB );") 

But why it works only with autocommit?

Original issue reported on code.google.com by Heptadec...@gmail.com on 4 Feb 2013 at 9:07