aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/www/quickstart.tcl
diff options
context:
space:
mode:
authordan miller2007-10-20 02:49:29 +0000
committerdan miller2007-10-20 02:49:29 +0000
commite36d23a85ebff914d74bb541558c2b6082b78edb (patch)
tree54b58fdf162e78af64055282a6035c8d2443389d /libraries/sqlite/unix/sqlite-3.5.1/www/quickstart.tcl
parent* Fixed an issue whereby avatar chat distances were being calculated against ... (diff)
downloadopensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.zip
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.gz
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.bz2
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.xz
sqlite source (unix build) added to libraries
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/www/quickstart.tcl')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/www/quickstart.tcl110
1 files changed, 110 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/www/quickstart.tcl b/libraries/sqlite/unix/sqlite-3.5.1/www/quickstart.tcl
new file mode 100644
index 0000000..8ae3d72
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/www/quickstart.tcl
@@ -0,0 +1,110 @@
1#
2# Run this TCL script to generate HTML for the quickstart.html file.
3#
4set rcsid {$Id: quickstart.tcl,v 1.8 2006/06/13 11:27:22 drh Exp $}
5source common.tcl
6header {SQLite In 5 Minutes Or Less}
7puts {
8<p>Here is what you do to start experimenting with SQLite without having
9to do a lot of tedious reading and configuration:</p>
10
11<h2>Download The Code</h2>
12
13<ul>
14<li><p>Get a copy of the prebuilt binaries for your machine, or get a copy
15of the sources and compile them yourself. Visit
16the <a href="download.html">download</a> page for more information.</p></li>
17</ul>
18
19<h2>Create A New Database</h2>
20
21<ul>
22<li><p>At a shell or DOS prompt, enter: "<b>sqlite3 test.db</b>". This will
23create a new database named "test.db". (You can use a different name if
24you like.)</p></li>
25<li><p>Enter SQL commands at the prompt to create and populate the
26new database.</p></li>
27<li><p>Additional documentation is available <a href="sqlite.html">here</a></li>
28</ul>
29
30<h2>Write Programs That Use SQLite</h2>
31
32<ul>
33<li><p>Below is a simple TCL program that demonstrates how to use
34the TCL interface to SQLite. The program executes the SQL statements
35given as the second argument on the database defined by the first
36argument. The commands to watch for are the <b>sqlite3</b> command
37on line 7 which opens an SQLite database and creates
38a new TCL command named "<b>db</b>" to access that database, the
39invocation of the <b>db</b> command on line 8 to execute
40SQL commands against the database, and the closing of the database connection
41on the last line of the script.</p>
42
43<blockquote><pre>
44#!/usr/bin/tclsh
45if {$argc!=2} {
46 puts stderr "Usage: %s DATABASE SQL-STATEMENT"
47 exit 1
48}
49load /usr/lib/tclsqlite3.so Sqlite3
50<b>sqlite3</b> db [lindex $argv 0]
51<b>db</b> eval [lindex $argv 1] x {
52 foreach v $x(*) {
53 puts "$v = $x($v)"
54 }
55 puts ""
56}
57<b>db</b> close
58</pre></blockquote>
59</li>
60
61<li><p>Below is a simple C program that demonstrates how to use
62the C/C++ interface to SQLite. The name of a database is given by
63the first argument and the second argument is one or more SQL statements
64to execute against the database. The function calls to pay attention
65to here are the call to <b>sqlite3_open()</b> on line 22 which opens
66the database, <b>sqlite3_exec()</b> on line 27 that executes SQL
67commands against the database, and <b>sqlite3_close()</b> on line 31
68that closes the database connection.</p>
69
70<blockquote><pre>
71#include &lt;stdio.h&gt;
72#include &lt;sqlite3.h&gt;
73
74static int callback(void *NotUsed, int argc, char **argv, char **azColName){
75 int i;
76 for(i=0; i&lt;argc; i++){
77 printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
78 }
79 printf("\n");
80 return 0;
81}
82
83int main(int argc, char **argv){
84 sqlite3 *db;
85 char *zErrMsg = 0;
86 int rc;
87
88 if( argc!=3 ){
89 fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
90 exit(1);
91 }
92 rc = <b>sqlite3_open</b>(argv[1], &db);
93 if( rc ){
94 fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
95 sqlite3_close(db);
96 exit(1);
97 }
98 rc = <b>sqlite3_exec</b>(db, argv[2], callback, 0, &zErrMsg);
99 if( rc!=SQLITE_OK ){
100 fprintf(stderr, "SQL error: %s\n", zErrMsg);
101 sqlite3_free(zErrMsg);
102 }
103 <b>sqlite3_close</b>(db);
104 return 0;
105}
106</pre></blockquote>
107</li>
108</ul>
109}
110footer {$Id: quickstart.tcl,v 1.8 2006/06/13 11:27:22 drh Exp $}