18.2. MySQL

 < Day Day Up > 

18.1. SQLite

SQLite is a public domain embeddable database that's implemented as a C library. In Mac OS X, it's also one of several backends used by the Core Data framework, which also uses XML and binary formats for storing persistent data.

18.1.1. Where to Find SQLite

You can find documentation, source code, and other SQLite resources at http://www.sqlite.org. However, Mac OS X Tiger includes SQLite 3 already installed. You'll find the header and library in the usual places (/usr/include/sqlite3.h and /usr/lib/libsqlite3.dylib), and the command-line interface in /usr/bin/sqlite3. Mac OS X Tiger also includes a Tcl (/usr/lib/sqlite3/libtclsqlite3.dylib) and PHP (/usr/lib/php/DB/sqlite.php) interface, and interfaces are available for many other languages.

18.1.2. Using SQLite

To use SQLite, simply start sqlite3 with the name of a database file. If the file doesn't exist, it will be created. You can use standard SQL statements to create, modify, and query data tables. There are a number of non-SQL commands that start with a dot, such as the indispensable .help and .quit.

     $ sqlite3 mydata.db     SQLite version 3.1.3     Enter ".help" for instructions     sqlite> CREATE TABLE foo (bar CHAR(10));     sqlite> INSERT INTO foo VALUES('Hello');     sqlite> INSERT INTO foo VALUES('World');     sqlite> SELECT * FROM foo;     Hello     World     sqlite> .quit 

You can also issue SQL commands in one-liners from the shell prompt:

     $ sqlite3 mydata.db 'SELECT * FROM foo;'     Hello     World 

     < Day Day Up > 


    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net