My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 137: sp_spaceused doesn't work on ASE15 with pyodbc
1 person starred this issue and may be notified of changes. Back to list
Status:  Duplicate
Merged:  issue 134
Owner:  ----
Closed:  Nov 2010


 
Reported by pedri...@gmail.com, Nov 17, 2010
What steps will reproduce the problem?
1. db = pyodbc.connect(...)
2. c = db.cursor()
3. c.execute('sp_spaceused object_name')

What is the expected output? What do you see instead?

The expected output is a cursor containing the result set from the stored procedure.

Instead I get this:

>>> c.execute("{call sp_spaceused some_table}")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.ProgrammingError: ('42000', '[42000] [FreeTDS][SQL Server]SELECT INTO command not allowed within multi-statement transaction.\n (226) (SQLExecDirectW)')


What version of the product are you using? On what operating system?
2.1.7, freetds, Sybase ASE 15.

Please provide any additional information below.

Is there anything that can be done to not implicitly set up a transaction, as I expect is happening here? This also happens when autocommit is set to False.


Nov 20, 2010
Project Member #1 mkleehammer
Autocommit defaults to False, you need to set it to true:

cnxn.autocommit = True
rows = c.execute("sp_spaceused object_name").fetchall()
cnxn.autocommit = False

or 

cnxn = pyodbc.connect(..., autocommit=True)
rows = ...

I've added something to the FAQ for this.  Thanks.

Status: Duplicate
Mergedinto: 134

Powered by Google Project Hosting