[SQLObject] IntCol not working - desparately need help
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Mike M. <mm...@wo...> - 2003-11-14 07:04:16
|
Hi, I have the following test code: from SQLObject import * import MySQLdb conn = MySQLdb.connect() conn.cursor().execute('create database mike') conn.close() compcode = 'mike' conn = MySQLConnection(user = '', db = 'mike') class Person(SQLObject): _connection = conn firstName = StringCol(length = 20, default = None) lastName = StringCol(length = 20, default = None) index = IntCol() Person.createTable(ifNotExists = True) p = Person.new(firstName = 'Mike', lastName = 'Moum') p = Person.new(firstName = 'Dean', lastName = 'Paque') < end code > When I try to run it, I get: [root@localhost test]# python sqlobjtest.py Traceback (most recent call last): File "sqlobjtest.py", line 18, in ? Person.createTable(ifNotExists = True) File "/usr/local/lib/python2.3/site-packages/SQLObject/SQLObject.py", line 965, in createTable cls._connection.createTable(cls) File "/usr/local/lib/python2.3/site-packages/SQLObject/DBConnection.py", line 271, in createTable self.query('CREATE TABLE %s (\n%s\n)' % \ File "/usr/local/lib/python2.3/site-packages/SQLObject/DBConnection.py", line 123, in query return self._runWithConnection(self._query, s) File "/usr/local/lib/python2.3/site-packages/SQLObject/DBConnection.py", line 72, in _runWithConnection val = meth(conn, *args) File "/usr/local/lib/python2.3/site-packages/SQLObject/DBConnection.py", line 120, in _query conn.cursor().execute(s) File "/usr/local/lib/python2.3/site-packages/MySQLdb/cursors.py", line 95, in execute return self._execute(query, args) File "/usr/local/lib/python2.3/site-packages/MySQLdb/cursors.py", line 114, in _execute self.errorhandler(self, exc, value) File "/usr/local/lib/python2.3/site-packages/MySQLdb/connections.py", line 33, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'INT\n)' at line 5") [root@localhost test]# When I comment out the IntCol field in the Person class, all is well. Please help! Am working on a program. Thanks, Mike -- the Moum's (Mike, Dede, Suzanne, Jeff, Kristen) Tipp City, Ohio, USA Visit the Baha'i World web site at www.bahai.org Visit the U.S. Baha'i web site at www.us.bahai.org |