Re: Problem with MySQL cursor

2007-10-12 Thread Florian Lindner
Carsten Haese wrote: > On Fri, 2007-10-12 at 13:12 +0200, Florian Lindner wrote: >> Carsten Haese wrote: >> > sql = "INSERT INTO "+DOMAIN_TABLE+"("+DOMAIN_FIELD+") VALUES (%s)" >> > executeSQL(sql, domainname) >> >> Ok, I understand it and now it works, but why is limitation? Why can't I >> just

Re: Problem with MySQL cursor

2007-10-12 Thread Carsten Haese
On Fri, 2007-10-12 at 13:12 +0200, Florian Lindner wrote: > Carsten Haese wrote: > > sql = "INSERT INTO "+DOMAIN_TABLE+"("+DOMAIN_FIELD+") VALUES (%s)" > > executeSQL(sql, domainname) > > Ok, I understand it and now it works, but why is limitation? Why can't I > just the string interpolation in a

Re: Problem with MySQL cursor

2007-10-12 Thread Diez B. Roggisch
Florian Lindner wrote: > Carsten Haese wrote: > >> On Thu, 2007-10-11 at 15:14 +0200, Florian Lindner wrote: >>> Hello, >>> I have a function that executes a SQL statement with MySQLdb: >>> >>> def executeSQL(sql, *args): >>> print sql % args >>> cursor = conn.cursor() >>> cursor.ex

Re: Problem with MySQL cursor

2007-10-12 Thread Florian Lindner
Carsten Haese wrote: > On Thu, 2007-10-11 at 15:14 +0200, Florian Lindner wrote: >> Hello, >> I have a function that executes a SQL statement with MySQLdb: >> >> def executeSQL(sql, *args): >> print sql % args >> cursor = conn.cursor() >> cursor.execute(sql, args) >> cursor.close

Re: Problem with MySQL cursor

2007-10-11 Thread Carsten Haese
On Thu, 2007-10-11 at 15:14 +0200, Florian Lindner wrote: > Hello, > I have a function that executes a SQL statement with MySQLdb: > > def executeSQL(sql, *args): > print sql % args > cursor = conn.cursor() > cursor.execute(sql, args) > cursor.close() > > it's called like that: >

RE: Problem with MySQL cursor

2007-10-11 Thread Sells, Fred
I don't think you can substitute the table name and column names in the execute, just values ( I could be wrong) try building it like this: sql = "INSERT INTO %s %s VALUES " % (taablename, columnstuple, '(%s)') cursor.execute(sql, values) > Hello, > I have a function that executes a SQL statemen

Re: Problem with MySQL cursor

2007-10-11 Thread J. Clifford Dyer
On Thu, Oct 11, 2007 at 03:14:30PM +0200, Florian Lindner wrote regarding Problem with MySQL cursor: > > Traceback (most recent call last): > File "manage.py", line 90, in ? > addDomain(domainName) > File "manage.py", line 27, in addDomain

Problem with MySQL cursor

2007-10-11 Thread Florian Lindner
Hello, I have a function that executes a SQL statement with MySQLdb: def executeSQL(sql, *args): print sql % args cursor = conn.cursor() cursor.execute(sql, args) cursor.close() it's called like that: sql = "INSERT INTO %s (%s) VALUES (%s)" executeSQL(sql, DOMAIN_TABLE,