On 18 Okt., 22:08, Paul McNett <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > On Oct 19, 7:32 am, Florian Lindner <[EMAIL PROTECTED]> wrote: > >> Hello, > >> I have a string: > > >> INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`, > >> `gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s) > > >> that is passed to a MySQL cursor from MySQLdb: > > >> ret = cursor.execute(sql, paras) > > >> paras is: > > >> ('flindner', '[EMAIL PROTECTED]', '/home/flindner/', '/home/ > >> flindner/Mail/test', 1001, 1001, '123') > > >> But that gives me an error: > > >> Traceback (most recent call last): > >> File "account.py", line 188, in ? > >> main() > >> File "account.py", line 33, in main > >> execute(action, account_type, options) > >> File "account.py", line 129, in execute > >> executeSQL(sql, options.username, options.login, options.home, > >> options.directory, options.uid, options.gid, options.password) > >> File "/home/flindner/common.py", line 29, in executeSQL > >> ret = cursor.execute(sql, paras) > >> File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line > >> 148, in execute > >> query = query % db.literal(args) > >> TypeError: int argument required > > >> I don't see errors in the format string or some other problem.... > > >> What's wrong? > > You should be using '?' for parameter bindings in your sql string not > > python format specifiers (you are after all writing sql here not > > python). > > > INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`, > > `gid`, `password`) VALUES (?, ?, ?, ?, ?, ?, ?) > > Sorry Tim, but that isn't correct: > > >>> import MySQLdb > >>> MySQLdb.paramstyle > > 'format' > > Florian, what happens when you replace your %i with %s?
That works! Thanks! But a weird error message for this solution... -- http://mail.python.org/mailman/listinfo/python-list