error <class 'gluon.contrib.pypyodbc.ProgrammingError'> ('', 'SQL_INVALID_HANDLE') when DAL is mssq

297 views
Skip to first unread message

Gianganh Nguyen

unread,
Dec 25, 2013, 3:22:35 AM12/25/13
to web...@googlegroups.com
Hi everybody!
In web2py, if I use db = DAL('mssql://...............), the error <class 'gluon.contrib.pypyodbc.ProgrammingError'> ('', 'SQL_INVALID_HANDLE') frequently occurs.
But if I use db = DAL('sqlite://storage.sqlite', pool_size = 1, everything is okie.
Please help me!

Alan Etkin

unread,
Dec 25, 2013, 6:17:49 PM12/25/13
to web...@googlegroups.com
In web2py, if I use db = DAL('mssql://...............), the error <class 'gluon.contrib.pypyodbc.ProgrammingError'> ('', 'SQL_INVALID_HANDLE') frequently occurs.

Can you please be more specific? What is the source code in you application producing the error?

Gianganh Nguyen

unread,
Dec 25, 2013, 8:35:33 PM12/25/13
to web...@googlegroups.com
This error is produced when the controller files execute a query string, example db(db.usr).select() or db(db.usr).count(). It does not always occur but frequently occur!
But after I press F5, it is okay.

Vào 06:17:49 UTC+7 Thứ năm, ngày 26 tháng mười hai năm 2013, Alan Etkin đã viết:

Alan Etkin

unread,
Dec 26, 2013, 12:21:28 PM12/26/13
to web...@googlegroups.com
This error is produced when the controller files execute a query string, example db(db.usr).select() or db(db.usr).count(). It does not always occur but frequently occur!

Have you checked <app>/databases/sql.log?

Maybe you can post the last commands stored for debugging.

Gianganh Nguyen

unread,
Dec 26, 2013, 10:13:36 PM12/26/13
to web...@googlegroups.com
Hey,
I resolved this issue follow:
1. Setup pyodbc-3.0.7.win32-py2.7.exe (download from http://code.google.com/p/pyodbc/downloads/list)
2. Insert to the db.py file:
import pyodbc
from gluon.dal import MSSQLAdapter

if not (MSSQLAdapter.driver):
    MSSQLAdapter.driver = globals().get('pyodbc',None)


And everything is okay.

Thanks!
(^_^)

Vào 00:21:28 UTC+7 Thứ sáu, ngày 27 tháng mười hai năm 2013, Alan Etkin đã viết:

Josh Myers

unread,
Jan 16, 2014, 5:57:18 PM1/16/14
to web...@googlegroups.com
I was also getting this same error and I thank Gianganh for his help in moving me along.

Now, using the solution above, instead of getting the SQL_INVALID_HANDLE, I am getting the following:

"<class 'pyodbc.Error'> ('HY000', 'The driver did not supply an error!')"

Gianganh, did you also get this error?  Or, if you didn't, do you know how I can fix this?


- Josh

Gianganh Nguyen

unread,
Jan 22, 2014, 10:17:56 PM1/22/14
to web...@googlegroups.com
Oh, I'm sorry because now I'm checking mail.
I didn't get that error. But I use driver pyodbc-3.0.7.win32-py2.7.exe for python2.7.5.
Are you using what is python's version?


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/gaP-XmMhMg0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Gianganhnguyen
CS - Soict - Hust - K52

Mobile: 0975814385
Reply all
Reply to author
Forward
0 new messages