Lukasz Szybalski wrote: > On 8/7/07, Carsten Haese <[EMAIL PROTECTED]> wrote: >> On Tue, 2007-08-07 at 13:06 -0500, Lukasz Szybalski wrote: >>> 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')") >> You are quoting the name in apostrophes (ascii character 39). You should >> be using backwards apostrophes (ascii character 96). > > Thank you, > That worked. > Lucas > _______________________________________________ > DB-SIG maillist - DB-SIG@python.org > http://mail.python.org/mailman/listinfo/db-sig
And as a general rule of thumb, don't use reserved words as column names in your database. Section 9.3 of the MySQL 5.1 reference manual lists all of these reserved words. I believe there is a similar section in the manuals for the other releases although I don't have any to hand at the moment. Regards, Andy -- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig