jeudi 1 octobre 2015

Parse date from string and insert with Sqlalchemy tosqlite

My problem has two subproblems (is that a word?):

A. Parse date from string.

I have datetime from rss feed that has format like below:

u'Wed, 30 Sep 2015 18:59:39 +0000'

What is most 'pythonic' way to make a datetime from string above? I tried to do it with regex but I had about 20 lines of code to do that and I hope there is simplier way to do it, preferably without regex. I also don't know what is easy way to change Sep to 09.

B. Insert to sqlite with Sqlalchemy

Here my problem is, I can't find example of code where I can see how to define column as datetime. Should it look like this?

t = Table('t', medatata, Column('my_date', Datetime)

And then just pass object of datetime to database?

Aucun commentaire:

Enregistrer un commentaire