key or user may be a reserved keyword in mysql and cannot used as a
field name.

On Dec 1, 2:08 pm, SergeyPo <[email protected]> wrote:
> Works under SQLite, but under MySQL table creation script generates
> the following sql: 'VARCHAR(16),\n\tcms_url VARCHAR(255),\n\tagency
> VARCHAR(32),\n\tuser VARCHAR(32),\n\tpas' - notice \n\t !
>
> Error traceback
>
> Traceback (most recent call last):
>
>   File "C:\web2py\gluon\restricted.py", line 184, in restricted
>
>     exec ccode in environment
>
>   File "C:/web2py/applications/tpa/models/db.py", line 19, in <module>
>
>     Field('password', 'string', length=32),
>
>   File "C:\web2py\gluon\sql.py", line 1205, in define_table
>
>     query = t._create(migrate=migrate, fake_migrate=fake_migrate)
>
>   File "C:\web2py\gluon\sql.py", line 1607, in _create
>
>     self._db._execute(query)
>
>   File "C:\web2py\gluon\sql.py", line 879, in <lambda>
>
>     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
>
>   File "c:\python26\lib\site-packages\MySQLdb\cursors.py", line 166,
> in execute
>
>     self.errorhandler(self, exc, value)
>
>   File "c:\python26\lib\site-packages\MySQLdb\connections.py", line
> 35, in defaulterrorhandler
>
>     raise errorclass, errorvalue
>
> 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 'VARCHAR(16),\n\tcms_url VARCHAR(255),\n\tagency
> VARCHAR(32),\n\tuser VARCHAR(32),\n\tpas' at line 4")
>
> In file: C:\web2py\applications\tpa/models/db.py
>
> # coding: utf8
>
>   import datetime
>
>   #db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or
> other DB
>
>   db=DAL('mysql://tpa:123...@localhost/tpa', pool_size=10)
>
>   ## if no need for session
>
> # session.forget()
>
>   from gluon.tools import Service
>
> service=Service(globals())                   # for json, xml, jsonrpc,
> xmlrpc, amfrpc
>
>   db.define_table('jurisdictions',
>
>     Field('name', 'string', length=32),
>
>     Field('key', 'string', length=16),
>
>     Field('cms_url', 'string', length=255),
>
>     Field('agency', 'string', length=32),
>
>     Field('user', 'string', length=32),
>
>     Field('password', 'string', length=32),
>
>     )

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to