Evan Martin (evan) wrote in evan_tech,
Evan Martin
evan
evan_tech

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".
Subscribe

  • blog moved

    As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • treemaps

    I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.

  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 3 comments