On Friday, November 14, 2003, at 02:04 AM, Mike Moum wrote:
> 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()
The word "index" is reserved in MySQL.
You should use
myIndex = IntCol()
if you have to have a separate index.
However, probably you could use the SQLObject 'id'
column for this, which is created automatically
for you:
class Person(SQLObject):
_connection = conn
firstName = StringCol(length=20, default=None)
lastName = StringCol(length=20, defaultNone)
>>> p = Person.new()
>>> print p.id
1
--
Randall Randall
ra...@ra...
|