On 8/7/07, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Tue, 2007-08-07 at 11:58 -0500, Lukasz Szybalski wrote:
> > Hello,
> > I have installed mysqldb python bindings and I am using python to
> > write to mysql.
> >
> > I have a field called "Desc" in a database (short for description )
> > But this name is used by mysql for sorting DESC
> >
> > When i do:
> > insert into tablename(id,desc)VALUES(1,'some text')
> >
> > How do I escape 'desc'?
>
> insert into tablename(id,`desc`) ...
>
>>> conn=MySQLdb.connect( SERVER, USER, PASS, DB )
>>> c=conn.cursor()
>>> c.execute("insert into tablename('desc')Values('sss')")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python25\lib\site-packages\MySQLdb\cursors.py", line 166, in execute
    self.errorhandler(self, exc, value)
  File "c:\Python25\lib\site-packages\MySQLdb\connections.py", line 35, in defau
lterrorhandler
    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 s
yntax to use near ''desc')Values('sss')' at line 1")


I was able to escape it on ODBC by doing 'DESC$' but that doesn't work for mysql
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to