1. andrew cooke
  2. c-orm

Wiki

Clone wiki

c-orm / ExamplePhonebook

Using the Example

Before showing the code, here's a simple example of how the phonebook application works:

    > example/src/phonebook4

    \help for help

    > bob 123456
    > bob 888888
    > alice 987654
    > bob
    bob: 123456
    bob: 888888
    > alice
    alice: 987654
    > bob -123456
    > bob
    bob: 888888
    > ^D

We can also check the database:

    > sqlite3 /tmp/phonebook 
    SQLite version 3.7.15.2 2013-01-09 11:53:05
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> .headers on
    sqlite> .tables
    name    number
    sqlite> select * from name;
    id|name
    1|bob
    2|alice
    sqlite> select * from number;
    id|number|name_id
    2|888888|1
    3|987654|2
    sqlite> 

OK, given the above, here is the source. There are three versions:

  • Simple - shows the basic functionality, with commentary in comments.

  • Complete - adds error handling (sorry, not yet ready).

  • Flow - as complete, but using the Flow macros.

Updated