I’ve been wanting to try something with libdrizzle since I added the server protocol interface. After an hour or two of hacking, I came up with:
lap> sqlite3 farm
SQLite version 3.5.9
sqlite> CREATE TABLE animals (
...> name VARCHAR(255) NOT NULL,
...> sound VARCHAR(255));
sqlite> INSERT INTO animals VALUES ("Cow", "Moo");
sqlite> SELECT * FROM animals;
Cow|Moo
sqlite>
Next, using a new program I hacked together in the libdrizzle examples directory:
./sqlite_server -m -v farm 54321
Now, in another terminal:
lap> mysql -h 127.0.0.1 -u root -P 54321
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: libdrizzle+SQLite
mysql> INSERT INTO animals VALUES ("Sheep", "Baa");
Query OK, 0 rows affected (0.14 sec)
mysql> SELECT * FROM animals;
+-------+-------+
| name | sound |
+-------+-------+
| Cow | Moo |
| Sheep | Baa |
+-------+-------+
2 rows in set (0.00 sec)
mysql> SELECT @@version_comment;
+------------------------------------+
| version |
+------------------------------------+
| SQLite Server using libdrizzle 0.1 |
+------------------------------------+
1 row in set (0.00 sec)
mysql>
There, now you make any SQLite database look like a Drizzle or MySQL server. The sqlite_server program is about 400 lines and only uses libsqlite3 and libdrizzle. For the curious, this is *not* included in the 0.1 release of libdrizzle, you’ll need to grab the latest source from Launchpad (bzr branch lp:libdrizzle). This was done quickly just for demonstration purposes, but if someone actually wants to make a project out of this I’d be happy to assist!
Now, what else can we slap a Drizzle/MySQL server interface on…? :)