transientskp / tkp

A transients-discovery pipeline for astronomical image-based surveys
http://docs.transientskp.org/
BSD 2-Clause "Simplified" License
19 stars 15 forks source link

database.py incorrect string formatting #504

Closed ajstewart closed 8 years ago

ajstewart commented 8 years ago

When I used database.py outside of trap to make a database connection, I've noticed when a connection fails the error message string formatting causes an error:

TypeError: not all arguments converted during string formatting

Line 188: logger.error("Query failed: %s. Query: %s." % (e, query % parameters))

I think it's either missing a %s and a comma in the inputs or there is one too many inputs, as I'm not exactly sure what variables the error message was intended to include.

https://github.com/transientskp/tkp/blob/master/tkp/db/database.py#L188

gijzelaerr commented 8 years ago

hm... the query should be populated with the parameters content, which is then shown in the eventual logger. When I compile this in my head it should just work, not sure what is going wrong here.

ajstewart commented 8 years ago

Actually yes you're right, I bet it's something with the scripts I was using that was accessing this function. I tested it again and did this time get it to report properly, it's probably that the parameters were not defined or passed properly in the scripts as this is the only way I can re-create it - e.g. the parameters variable is not a dictionary.

I'll close it as it does seem to be an external problem.

gijzelaerr commented 8 years ago

yes, if you don't specify all the named arguments in the query string python formatting will complain.