Introducing Squeak, an open source SQLite schema editor

To just view or download the code, click here.

I love SQLite, I really do. For any quick and dirty development, there is no other relational database like it: it's fast, lightweight, ultra portable, DB-API 2.0 compliant, and baked right into any distro of Python 2.5 or higher.

Using it is generally a very positive experience right up until the point where you need to make any changes to a table's schema. I distinctly remember that when learning Django it was particularly annoying to have to do a little SQLite dance every time I would need to edit or remove a model field.

It is to scratch that itch that I've created Squeak, which is a python module that can be used as a script from the command line or as a library that lets you:

  • Drop a table column
  • Rename a table column
  • Change the definition of a table column (for example foreign key relationships or constraints)

Here is a test scenario where a column gets dropped from a table schema:

$ sqlite3 db
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE "my_table" (
   ...>     "id" integer NOT NULL PRIMARY KEY,
   ...>     "name" varchar (20) NOT NULL DEFAULT ""
   ...> )
   ...> ;
sqlite> .quit

$ ./squeak.py db my_table drop_column name
Column 'name' dropped

$ sqlite3 db .schema
CREATE TABLE "my_table" (
    "id" integer NOT NULL PRIMARY KEY
);

For more examples and further details, please visit the project's GitHub page at http://github.com/teebes/squeak

Disclaimer:

Squeak should be used for development purposes only. It is not meant to be used on production systems and is nowhere near fool proof.

0 comments - leave a comment

Leave a comment







Twitter

Sep 04 - It's so much easier to understand a solution once you've experienced the problem

Sep 03 - @tarequeh @shawnr I did see that, very excited to see what Mr Rider has to say :)

Sep 03 - Doing it, buying The Suburbs by @arcadefire. We Used to Wait really got stuck in my head after http://thewildernessdowntown.com/