Gadfly incorporates a TCP/IP client and server, transforming it into a proper client/server system. To start the server on the machine we’ve already tested, run the following command from a DOS prompt:
C:\MYDIR\gadfly>python gfserve.py 2222 test dbtest admin
The arguments specify the port, the database name, the database directory, and the password. The server console should start up and display the message “waiting for connections.”
The client machine needs only the two files, gfclient.py and gfsocket.py (as well as Python, of course). At 15 KB, this must be one of the lightest database clients around. On the client machine, start Python and run the following commands. If you don’t have a second PC handy, you can run the client from a second DOS prompt (or PythonWin prompt) on the same machine provided TCP/IP is properly installed:
>>> # on client machine >>> from gfclient import gfclient >>> # connect with policy, port, password, machine name >>> conn = gfclient("admin",2222, "admin", "tahoe") >>> cursor = conn.cursor() >>> cursor.execute('SELECT * FROM LIKES') >>> pprint(cursor.fetchall()) [(2, 'bud', 'adam'), (1, 'rollingrock', 'wilt'), (2, 'bud', 'sam'), (3, 'rollingrock', 'norm'), (2, 'bud', 'norm'), (1, 'sierranevada', 'nan'), (2, 'pabst', 'woody'), (5, 'mickies', 'lola')] >>>
As the queries execute, you should see messages on the server console.