Yagiz Degirmenci
Yagiz Degirmenci

Reputation: 20598

sqlite3 and sqlalchemy stores a different datetime

I'm trying to create a async database for my api, but when i insert a datetime, it stores a different value. The database schema that i created in my Python files.

prices = sqlalchemy.Table(
"prices",
metadata,
sqlalchemy.Column("id", sqlalchemy.String),
sqlalchemy.Column("value", sqlalchemy.String),
sqlalchemy.Column("date", sqlalchemy.DateTime, primary_key=True),)

I tried to insert a datetime manually with the ISO 8601(YYYY-MM-DD) format;

insert into prices (date) values (2001-08-27);
insert into prices (date) values (2000-04-21);

But when i check the database, i see this weird result;

sqlite> select * from prices;
||1966
||1975

Is there a spesific reason why or am i missing something?

Upvotes: 0

Views: 139

Answers (1)

Balaji Ambresh
Balaji Ambresh

Reputation: 5037

You've got to quote the values. Here's an example:

sqlite> insert into prices (date) values ('2001-08-27');
sqlite> select date from prices;
2001-08-27

Upvotes: 1

Related Questions