Glenn Yonemitsu - software engineer. yonemitsu@gmail.com

Super Fast Prototyping With Sqlite

SQLite was famously known for ignoring column types.

So a table like this:

CREATE TABLE post (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT,
    content TEXT
);

Can still have incompatible data types inserted:

INSERT INTO post (title, content) VALUES (123, 456.78); -- this is valid

This kind of works for quick prototyping but there are a couple of ways to make it even easier.

First, use the implicit rowid instead of INTEGER PRIMARY KEY AUTOINCREMENT.

CREATE TABLE post (
    title TEXT,
    content TEXT
);

INSERT INTO
    post (title, content)
VALUES
    ("First post", "Hello, World!");

SELECT
    rowid, -- or `oid` or `_rowid_`
    title,
    content
FROM
    post;

And now take it further and just drop the types!

CREATE TABLE post (title, content);

Now you have a table where you can stuff with whatever data. This should be acceptable since this is a prototype after all. And you automatically get an incrementing primary key as well.

References