MySQL Issue: "not enough arguements for format string" error in migration

1,265 views
Skip to first unread message

Rodney Haynie

unread,
May 30, 2009, 12:42:50 PM5/30/09
to sqlal...@googlegroups.com

(I hope this formats correctly. It seems, sometimes when I copy paste
from my text editor, the email gets strung together in one line.)

I have a migration problem that may be an issue in SA, SA-Migrations or
MySQLdb.

OK, I am narrowing the migration problem down and it looks like an issue
with mysqldb and/or mysql. In particular someone does not like
STR_TO_DATE(). I can run the SELECT statement with no problem from
mySQL Query Browser, and it gives me a valid datetime type.

I created a super stripped down version of the code. Basically I am
just adding a stored procedure to the database... I've done it in
previous migrations, but this one fails.

MySQLdb version: 1.2.2 (There might be 1.2.3 available... I'll look
into it.)

mySQL version: "5.0.67-community-nt"

1. Upgrade script:
-- Example of "not enough arguements for format string" problem.
CREATE PROCEDURE my_issue()
BEGIN
select STR_TO_DATE('01/20/2008 19:44:02', '%c/%d/%Y %T');
END;
;


2. Downgrade script:

DROP PROCEDURE my_issue;


3. Traceback
C:\svn\ECWeb\ec>managelocal.py upgrade
13 -> 14...
Traceback (most recent call last):
File "C:\svn\ECWeb\ec\manageLocal.py", line 4, in <module>

main(url='mysql://rodney:thepass@localhost:3306/ECWebTest',repository='migrati
on')
File
"c:\python25\lib\site-packages\sqlalchemy_migrate-0.5.2-py2.5.egg\migrate
\versioning\shell.py", line 140, in main
ret = command(**kwargs)
File
"c:\python25\lib\site-packages\sqlalchemy_migrate-0.5.2-py2.5.egg\migrate
\versioning\api.py", line 229, in upgrade
return _migrate(url, repository, version, upgrade=True, err=err, **opts)
File
"c:\python25\lib\site-packages\sqlalchemy_migrate-0.5.2-py2.5.egg\migrate
\versioning\api.py", line 269, in _migrate
schema.runchange(ver, change, changeset.step)
File
"c:\python25\lib\site-packages\sqlalchemy_migrate-0.5.2-py2.5.egg\migrate
\versioning\schema.py", line 183, in runchange
change.run(self.engine, step)
File
"c:\python25\lib\site-packages\sqlalchemy_migrate-0.5.2-py2.5.egg\migrate
\versioning\script\sql.py", line 20, in run
conn.execute(text)
File
"c:\python25\lib\site-packages\sqlalchemy-0.5.3-py2.5.egg\sqlalchemy\engi
ne\base.py", line 824, in execute
return Connection.executors[c](self, object, multiparams, params)
File
"c:\python25\lib\site-packages\sqlalchemy-0.5.3-py2.5.egg\sqlalchemy\engi
ne\base.py", line 888, in _execute_text
return self.__execute_context(context)
File
"c:\python25\lib\site-packages\sqlalchemy-0.5.3-py2.5.egg\sqlalchemy\engi
ne\base.py", line 896, in __execute_context
self._cursor_execute(context.cursor, context.statement,
context.parameters[0
], context=context)
File
"c:\python25\lib\site-packages\sqlalchemy-0.5.3-py2.5.egg\sqlalchemy\engi
ne\base.py", line 948, in _cursor_execute
self.dialect.do_execute(cursor, statement, parameters, context=context)
File
"c:\python25\lib\site-packages\sqlalchemy-0.5.3-py2.5.egg\sqlalchemy\engi
ne\default.py", line 122, in do_execute
cursor.execute(statement, parameters)
File
"C:\Python25\lib\site-packages\mysql_python-1.2.2-py2.5-win32.egg\MySQLdb
\cursors.py", line 151, in execute
TypeError: not enough arguments for format string

C:\svn\ECWeb\ec>

Thanks for any help.
-Rodney

Michael Bayer

unread,
May 31, 2009, 10:51:43 AM5/31/09
to sqlal...@googlegroups.com
perhaps you need to escape a percent sign as in %% .

Rodney Haynie

unread,
May 31, 2009, 12:55:04 PM5/31/09
to sqlal...@googlegroups.com
Fantastic Michael.  That was a good "gotcha" for me.
After I escaped the 4 % signs I had in the test, it worked just fine.

Thanks.
-Rodney
Reply all
Reply to author
Forward
0 new messages