user3527975 user3527975 - 2 years ago 318
SQL Question

Convert from sqlalchemy to a string

Is it possible to convert the result of from sqlalchemy to a string object? Something along the lines of'%m/%d/%Y')

I want to use this result in a raw sqlalchemy that updates a datetime column in mysql. This query accepts only string parameters.

Answer Source

Using str( returns now() which is the SQL function for using the current timestamp. In other words, if you're constructing a raw query you can pass that in directly and MySQL will automatically fill in the current timestamp. If you want to pass in something along the lines of %m/%d/%Y, then is not the appropriate tool to use.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download