I'm taking data that's been encoded into schemaless JSON and inserting
it into a table.  For simplicity's sake, let's say I have a table like
this:

CREATE TABLE some_table(
    id INT PRIMARY KEY,
    insert_date DATETIME
    );

When I get the input data, it would look something like this:

{id: 1,
 insert_date: "2008 10 29"}

The code to insert this would look something like this (obviously
simplified - data is the above JSON structure encoded into a python
dictionary):

metadata.reflect()
table = metadata.tables[table_name]
stmt = table.insert(data)
session.execute(stmt)

In this case, insert_date would seem to be going into the database
like this:  "0000-00-00 00:00:00".  Is there a way I can tell the
compiler how to compile this?  Ideally, I'd like to be able to do
something like this at the start of my program:

DATETIME.format_str = "yyyy mm dd"

...or better yet, have a way to use python-dateutil[1] to parse the
datetime string.  Any advice?

[1] http://labix.org/python-dateutil

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to