# # Run this TCL script to generate HTML for the quickstart.html file. # set rcsid {$Id: quickstart.tcl,v 1.1 2002/08/15 13:45:17 drh Exp $} puts {
Here is what you do to start experimenting with SQLite without having to do a lot of tedious reading and configuration:
Get a copy of the prebuild binaries for your machine, or get a copy of the sources and compile them yourself. Visit the download page for more information.
At a shell or DOS prompt, enter: "sqlite test.db". This will create a new database named "test.db". (You can use a different name if you like.)
Enter SQL commands at the prompt to create and populate the new database.
Below is a simple TCL program that demonstrates how to use the TCL interface to SQLite. The program executes the SQL statements given as the second argument on the database defined by the first argument.
#!/usr/bin/tclsh if {$argc!=2} { puts stderr "Usage: %s DATABASE SQL-STATEMENT" exit 1 } load /usr/lib/tclsqlite.so Sqlite sqlite db [lindex $argv 0] db eval [lindex $argv 1] x { foreach v $x(*) { puts "$v = $x($v)" } puts "" } db close
Below is a simple C program that demonstrates how to use the C/C++ interface to SQLite. The name of a database is given by the first argument and the second argument is one or more SQL statements to execute against the database.
#include <stdio.h> #include <sqlite.h> static int callback(void *NotUsed, int argc, char **argv, char **azColName){ int i; for(i=0; i<argc; i++){ printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL"); } printf("\n"); return 0; } int main(int argc, char **argv){ sqlite *db; char *zErrMsg = 0; int rc; if( argc!=3 ){ fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]); exit(1); } db = sqlite_open(argv[1], 0, &zErrMsg); if( db==0 ){ fprintf(stderr, "Can't open database: %s\n", &zErrMsg); exit(1); } rc = sqlite_exec(db, argv[2], callback, 0, &zErrMsg); if( rc!=SQLITE_OK ){ fprintf(stderr, "SQL error: %s\n", zErrMsg); } sqlite_close(db); return 0; }