mysql connection error

254 views
Skip to first unread message

thomas

unread,
Apr 30, 2008, 1:12:02 PM4/30/08
to web2py Web Framework
Traceback (most recent call last):
File "/home/thomas/web2py/gluon/restricted.py", line 62, in
restricted
exec ccode in environment
File "/home/thomas/web2py/applications/test/models/mysql.py", line
3, in <module>
mysql=SQLDB("mysql://root:root@localhost:3306/test")
File "/home/thomas/web2py/gluon/sql.py", line 294, in __init__
self._connection=MySQLdb.Connection(db=db,
NameError: global name 'MySQLdb' is not defined



mysql.py

# try something like
#mysql=SQLDB("sqlite://mysql.db")
mysql=SQLDB("mysql://root:root@localhost:3306/test")


Any ideea?
Thanks,
thomas

voltron

unread,
Apr 30, 2008, 1:52:12 PM4/30/08
to web2py Web Framework
did you install the mysqldb module? (http://sourceforge.net/projects/
mysql-python)

Massimo Di Pierro

unread,
Apr 30, 2008, 1:58:52 PM4/30/08
to web...@googlegroups.com
To use mysql you need to run from source and install the MySQLdb
driver since I am not allowed to distriute the driver with web2py.
Sorry.

Massimo

thomas

unread,
Apr 30, 2008, 7:51:39 PM4/30/08
to web2py Web Framework
Ok, it's all right.

I installed python-mysqldb driver.

How do I install the driver for oracle? (I use Debian)

Thank you very much,
thomas

PS: I have no experience with python based frameworks.

Massimo Di Pierro

unread,
Apr 30, 2008, 9:17:23 PM4/30/08
to web...@googlegroups.com

thomas

unread,
Apr 30, 2008, 11:17:26 PM4/30/08
to web2py Web Framework
Ok, thank you
I installed the cx_Oracle driver also but I have another error:

Traceback (most recent call last):
File "/home/thomas/web2py/gluon/restricted.py", line 62, in
restricted
exec ccode in environment
File "/home/thomas/web2py/applications/test/models/db1.py", line 8,
in <module>
db1.define_table('image', SQLField('title'),
SQLField('file','upload'))
File "/home/thomas/web2py/gluon/sql.py", line 355, in define_table
raise e
DatabaseError: ORA-00904: : invalid identifier

db1.py:

# try something like
#db1=SQLDB("sqlite://db1.db")

#db1=SQLDB("mysql://root:ro...@127.0.0.1:3306/test")
db1=SQLDB("oracle://system/password@xe")

db1.define_table('image', SQLField('title'),
SQLField('file','upload'))

I didn't found a syntax error.

Thanks,
thomas

mdipierro

unread,
May 1, 2008, 7:37:43 AM5/1/08
to web2py Web Framework
This is a database error
> DatabaseError: ORA-00904: : invalid identifier
I suspect Oracle does not like the use of "file" for field name or
"image" for table name. Ore or the other are reserved keywords.
Reply all
Reply to author
Forward
0 new messages