[egenix-users] Initial Install - Error 'vars not set'
M.-A. Lemburg
mal at egenix.com
Fri Jun 9 19:52:50 CEST 2006
Nick Albright wrote:
>
> Hello again!
>
> I've got some more debug data. I've got output form the ODBC trace as
> well, but I can't make much out, other than I see that the that the select
> statement is making it through.
The ODBC trace won't help much here, since mxODBC is reporting
an internal error.
Please compile mxODBC with debugging enabled and send us
the generated mxODBC.log. This will have more interesting
details :-) ...
http://www.egenix.com/files/python/mxODBC.html#Debugging
Apart from that, Charlie is right: FreeTDS tends to produce
lots of weird errors. Better use one of the commercial
ODBC drivers or an ODBC-ODBC bridge.
Which versions of mxODBC, FreeTDS and iODBC are you using ?
Have you setup FreeTDS correctly ? (e.g. it is possible that
the TDS version is not correctly set)
> -----Begin Trace------
> ** iODBC Trace file
> ** Trace started on Fri Jun 09 11:08:00 2006
> ** Driver Manager: 03.52.0406.0126
>
>
> [000000.000176]
> python 2A95562500 ENTER SQLAllocEnv
> SQLHENV * 0x2a989dfd10
>
> [000000.000204]
> python 2A95562500 EXIT SQLAllocEnv with return code 0 (SQL_SUCCESS)
> SQLHENV * 0x2a989dfd10 (0x522f00)
>
> [000000.000603]
> python 2A95562500 ENTER SQLAllocConnect
> SQLHENV 0x522f00
> SQLHDBC * 0x2a955dd770
>
> [000000.000634]
> python 2A95562500 EXIT SQLAllocConnect with return code 0 (SQL_SUCCESS)
> SQLHENV 0x522f00
> SQLHDBC * 0x2a955dd770 (0x5720a0)
>
> [000000.000663]
> python 2A95562500 ENTER SQLConnect
> SQLHDBC 0x5720a0
> SQLCHAR * 0x2a955caf54
> | MSSQL |
> SQLSMALLINT -3 (SQL_NTS)
> SQLCHAR * 0x2a955cac24
> | USER |
> SQLSMALLINT -3 (SQL_NTS)
> SQLCHAR * 0x2a98a1d174
> | **** |
> SQLSMALLINT -3 (SQL_NTS)
>
> [000000.083548]
> python 2A95562500 EXIT SQLConnect with return code 0 (SQL_SUCCESS)
> SQLHDBC 0x5720a0
> SQLCHAR * 0x2a955caf54
> SQLSMALLINT -3 (SQL_NTS)
> SQLCHAR * 0x2a955cac24
> SQLSMALLINT -3 (SQL_NTS)
> SQLCHAR * 0x2a98a1d174
> SQLSMALLINT -3 (SQL_NTS)
>
> [000000.083632]
> python 2A95562500 ENTER SQLGetFunctions
> SQLHDBC 0x5720a0
> SQLUSMALLINT 58 (SQL_API_SQLDESCRIBEPARAM)
> SQLUSMALLINT * 0x7fbffff45e
>
> [000000.083672]
> python 2A95562500 EXIT SQLGetFunctions with return code 0 (SQL_SUCCESS)
> SQLHDBC 0x5720a0
> SQLUSMALLINT 58 (SQL_API_SQLDESCRIBEPARAM)
> SQLUSMALLINT * 0x7fbffff45e (0)
>
> [000000.083707]
> python 2A95562500 ENTER SQLGetInfo
> SQLHDBC 0x5720a0
> SQLUSMALLINT 81 (SQL_GETDATA_EXTENSIONS)
> SQLPOINTER 0x7fbffff460
> SQLSMALLINT 32
> SQLSMALLINT * 0x7fbffff45c
>
> [000000.083753]
> python 2A95562500 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS)
> SQLHDBC 0x5720a0
> SQLUSMALLINT 81 (SQL_GETDATA_EXTENSIONS)
> SQLPOINTER 0x7fbffff460 (0x4)
> | SQL_GD_BLOCK |
> SQLSMALLINT 32
> SQLSMALLINT * 0x7fbffff45c (4)
>
> [000000.083800]
> python 2A95562500 ENTER SQLGetInfo
> SQLHDBC 0x5720a0
> SQLUSMALLINT 46 (SQL_TXN_CAPABLE)
> SQLPOINTER 0x7fbffff460
> SQLSMALLINT 32
> SQLSMALLINT * 0x7fbffff45c
>
> [000000.083839]
> python 2A95562500 EXIT SQLGetInfo with return code 0 (SQL_SUCCESS)
> SQLHDBC 0x5720a0
> SQLUSMALLINT 46 (SQL_TXN_CAPABLE)
> SQLPOINTER 0x7fbffff460 (2)
> | SQL_TC_ALL |
> SQLSMALLINT 32
> SQLSMALLINT * 0x7fbffff45c (2)
>
> [000000.083885]
> python 2A95562500 ENTER SQLSetConnectOption
> SQLHDBC 0x5720a0
> SQLUSMALLINT 102 (SQL_AUTOCOMMIT)
> SQLLEN 0
>
> [000000.084150]
> python 2A95562500 EXIT SQLSetConnectOption with return code 0 (SQL_SUCCESS)
> SQLHDBC 0x5720a0
> SQLUSMALLINT 102 (SQL_AUTOCOMMIT)
> SQLLEN 0
>
> [000000.084209]
> python 2A95562500 ENTER SQLAllocStmt
> SQLHDBC 0x5720a0
> SQLHSTMT * 0x2a955d0fc0
>
> [000000.084249]
> python 2A95562500 EXIT SQLAllocStmt with return code 0 (SQL_SUCCESS)
> SQLHDBC 0x5720a0
> SQLHSTMT * 0x2a955d0fc0 (0x51e860)
>
> [000000.084286]
> python 2A95562500 ENTER SQLFreeStmt
> SQLHSTMT 0x51e860
> SQLUSMALLINT 0 (SQL_CLOSE)
>
> [000000.084319]
> python 2A95562500 EXIT SQLFreeStmt with return code 0 (SQL_SUCCESS)
> SQLHSTMT 0x51e860
> SQLUSMALLINT 0 (SQL_CLOSE)
>
> [000000.084346]
> python 2A95562500 ENTER SQLExecDirect
> SQLHSTMT 0x51e860
> SQLCHAR * 0x2a955ccdd4
> | SELECT COUNT(*) AS c FROM items |
> SQLINTEGER 31
>
> [000000.088062]
> python 2A95562500 EXIT SQLExecDirect with return code 0 (SQL_SUCCESS)
> SQLHSTMT 0x51e860
> SQLCHAR * 0x2a955ccdd4
> SQLINTEGER 31
>
> [000000.088122]
> python 2A95562500 ENTER SQLNumResultCols
> SQLHSTMT 0x51e860
> SQLSMALLINT * 0x7fbffff44e
>
> [000000.088146]
> python 2A95562500 EXIT SQLNumResultCols with return code 0 (SQL_SUCCESS)
> SQLHSTMT 0x51e860
> SQLSMALLINT * 0x7fbffff44e (1)
>
> [000000.088172]
> python 2A95562500 ENTER SQLRowCount
> SQLHSTMT 0x51e860
> SQLLEN * 0x7fbffff448
>
> [000000.088198]
> python 2A95562500 EXIT SQLRowCount with return code 0 (SQL_SUCCESS)
> SQLHSTMT 0x51e860
> SQLLEN * 0x7fbffff448 (-1)
>
> [000000.090037]
> python 2A95562500 ENTER SQLFreeStmt
> SQLHSTMT 0x51e860
> SQLUSMALLINT 3 (SQL_RESET_PARAMS)
>
> [000000.090108]
> python 2A95562500 EXIT SQLFreeStmt with return code 0 (SQL_SUCCESS)
> SQLHSTMT 0x51e860
> SQLUSMALLINT 3 (SQL_RESET_PARAMS)
>
> [000000.090143]
> python 2A95562500 ENTER SQLCancel
> SQLHSTMT 0x51e860
>
> [000000.090468]
> python 2A95562500 EXIT SQLCancel with return code 0 (SQL_SUCCESS)
> SQLHSTMT 0x51e860
>
> [000000.090492]
> python 2A95562500 ENTER SQLFreeStmt
> SQLHSTMT 0x51e860
> SQLUSMALLINT 1 (SQL_DROP)
>
> [000000.090526]
> python 2A95562500 EXIT SQLFreeStmt with return code 0 (SQL_SUCCESS)
> SQLHSTMT 0x51e860
> SQLUSMALLINT 1 (SQL_DROP)
>
> [000000.090558]
> python 2A95562500 ENTER SQLDisconnect
> SQLHDBC 0x5720a0
>
> [000000.090618]
> python 2A95562500 EXIT SQLDisconnect with return code 0 (SQL_SUCCESS)
> SQLHDBC 0x5720a0
>
> [000000.090646]
> python 2A95562500 ENTER SQLFreeConnect
> SQLHDBC 0x5720a0
>
> [000000.090669]
> python 2A95562500 EXIT SQLFreeConnect with return code 0 (SQL_SUCCESS)
> SQLHDBC 0x5720a0
>
> [000000.091991]
> python 2A95562500 ENTER SQLFreeEnv
> SQLHENV 0x522f00
>
> [000000.092035]
> python 2A95562500 EXIT SQLFreeEnv with return code 0 (SQL_SUCCESS)
> SQLHENV 0x522f00
>
> ** Trace finished on Fri Jun 09 11:08:00 2006
> -----End Trace-----
>
>
> Any suggestions?
>
> Thanks for your time,
> -Nick
>
>
> On Wed, 7 Jun 2006, Nick Albright wrote:
>
>>
>> Hello! I was wondering if anyone could help me troubleshoot my fresh
>> install of mxODBC. I'm using iODBC with freeTDS to connect to a MS SQL
>> server. I execute a select statement and do a fetchone() and I get the
>> error:
>>
>> -----Begin Error-----
>> Traceback (most recent call last):
>> File "tmp/sql_test.py", line 35, in ?
>> data = curs.fetchone()
>> mxODBC.InterfaceError: mxODBCursor_Fetch called, but vars not set
>> -----Begin Error-----
>>
>>
>> The full code is:
>>
>> -----Begin Code-----
>> import mx.ODBC.iODBC as A
>>
>> db = A.connect( "MSSQL", "USER", "PASS" )
>>
>> curs = db.cursor()
>>
>> curs.execute( "SELECT COUNT(*) AS c FROM items" )
>>
>> data = curs.fetchone()
>>
>> print data
>> -----End Code-----
>>
>>
>> And I believe the odbc and freetds side is setup correctly as I can use
>> isql just fine:
>>
>> -----Begin isql-----
>> $ isql -v MSSQL USER PASS
>> +---------------------------------------+
>> | Connected! |
>> | |
>> | sql-statement |
>> | help [tablename] |
>> | quit |
>> | |
>> +---------------------------------------+
>> SQL> SELECT COUNT(*) AS c FROM items;
>> +------------+
>> | c |
>> +------------+
>> | 3897 |
>> +------------+
>> SQLRowCount returns 1
>> 1 rows fetched
>> SQL>
>> -----End isql-----
>>
>>
>> I know it is connecting OK, as if I change any of the connection
>> parameters, I get an exception connecting. However, it is strange in that
>> if I change iODBC to unixODBC (Which I don't have installed), I get the
>> same error.. And after the execute the curs.rowcount is -1.
>>
>> Any help would be most appreciated.
>>
>> Thanks for your time,
>> -Nick
>>
>
> ---
> "I'm happy with where I'm at now. Its never good enough of course, but
> I'm not extremely pissed at least."
>
> -- John Mancine on some code (1/10/2005)
>
>
>
> _______________________________________________________________________
> eGenix.com User Mailing List http://www.egenix.com/
> https://www.egenix.com/mailman/listinfo/egenix-users
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Jun 09 2006)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2006-07-03: EuroPython 2006, CERN, Switzerland 23 days left
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the egenix-users
mailing list