Simple Database Library
Ulric's Router Construction Kit
Sometimes linking directly with the library isn't practical,
perhaps because an application is being distributed in binary form
and there's no way to know what database will be used, or perhaps
the application will be run on a different machine from where the
database client libraries are installed.
Sdbd to the rescue! This is a proxy daemon which handles the database
communication on behalf of the application. As a result, there is
no need for the application to be linked to database libraries or even
libsdb itself; all that is handled by sdbd.
An example client is provided in sdbd_client.c.
It is very similar
to sdb_client, except that it doesn't use any libsdb calls. Example:
ulric@host1$ sdbd 2222
ulric@host2$ sdbd_client host1 2222 postgres:host=host1:db=testdb
sdbd> select * from foo
In this case, the database, the client libraries and libsdb are all
installed on host1. Nothing except sdbd_client is needed on host2.
Description of the protocol, as seen on the wire:
Everything is sent in ascii form, so it can be debugged by humans.
- Client sends url
- Server sends single space as acknowledgement
- Client sends query string
- Server sends number of columns in result, space-terminated
- Server sends column size in bytes, space-terminated
- Server sends column contents
- 5-6 are repeated for all additional columns
- 4-7 are repeated for all additional result rows
- Server sends the number 0.
sh-2.05$ telnet localhost 2222
Connected to localhost.
Escape character is '^]'.
select * from foo
2 7 Matilda8 Eriksson2 5 Ulric8 Eriksson2 4 Joel8 Eriksson0
Connection closed by foreign host.