evan_tech

Previous Entry Share Next Entry
11:39 pm, 25 Apr 06

sqlite3 weak types gotcha

sqlite> create table test (subject string);
sqlite> insert into test values ('2.0');
sqlite> select * from test;
2
What if, y'know, I had a program that wanted to actually store the string "2.0" in a database and be able to fetch it back later? Ok, that's not hypothetical.

The trick is that while sqlite generally ignores the column types you give it, the proper type for string columns is "text" and not "string" or "char".