sqlite problem with datetime format YYYY-MM-DDTHH:mm:ss
3,192 views
Skip to first unread message
Massi
unread,
Sep 3, 2015, 8:05:50 AM9/3/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalchemy
Hi everyone,
I'm trying to use sqlalchemy (0.9.10) to read a sqlite table which contains some datetime columns. As the title says these column are given in the format YYYY-MM-DDTHH:mm:ss (I did not create the table). When I execute the query, it succeeds, but when I try to convert the rows to lists I get the following error:
If I try to create a similar table via sqlalchemy and then to read the data everything works fine. The data in this case is stored in the format YYYY-MM-DD HH:mm:ss. Any hint?
Thanks in advance!
Simon King
unread,
Sep 3, 2015, 9:54:45 AM9/3/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlal...@googlegroups.com
You could try passing the regexp parameter to the DateTime column in
your table definition:
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalchemy
Hi Simone,
thank you for your reply. Unfortunately I don't create the table so I don't define the table, I only load it from the DB. I hope I intended your suggestion correctly.
Thanks again.
Simon King
unread,
Sep 3, 2015, 11:18:29 AM9/3/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlal...@googlegroups.com
That's fine - the "regexp" argument is only used when interpreting the
data that comes back from sqlite - it doesn't depend on you actually
creating the table from SQLAlchemy.
It does require that you have an in-python "definition" of the table
structure, which I assume you already have, unless you are simply
using SQLAlchemy to issue raw SQL to sqlite. Do you have any table
definitions in your Python code, or are you using reflection?
If you are using reflection, you can override specific column
definitions as described at