Merge branch 'master' of github.com:tgiphil/mono
[mono.git] / web / sqlite
1 * SQL Lite Data Provider
2
3 <ul>
4         <li>ADO.NET Data Provider for 
5         the <a href"http://www.hwaci.com/sw/sqlite/">SQL Lite</a> which 
6         is an embeddable SQL database engine</li>
7
8         <li>From the SQL Lite web page: SQLite is a C library that \r
9         implements an embeddable SQL database engine. Programs that link with \r
10         the SQLite library can have SQL database access without \r
11         running a separate RDBMS process. The distribution \r
12         comes with a standalone command-line access program (sqlite) that \r
13         can be used to administer an SQLite database and which serves \r
14         as an example of how to use the SQLite library.  SQLite is not a client library \r
15         used to connect to a big database server. SQLite is the server. The SQLite \r
16         library reads and writes directly to and from the database files on disk.</li>\r
17
18         <li>SQL Lite can be downloaded 
19         from <a href="http://www.hwaci.com/sw/sqlite/download.html">here</a>.
20         binaries exist for Linux and Windows.  sqlite.dll on Windows 
21         and sqlite.so on Linux.  The source code is available too.</li>
22
23         <li>Exists in namespace and assembly Mono.Data.SqliteClient</li>
24         
25         <li>Created by Vladimir Vukicevic so he could have a database of
26         thumbnail images for mPhoto.  mPhoto is GUI application 
27         for cataloging images.  mPhoto runs on Mono 
28         and uses <a href="http://www.go-mono.com/gtk-sharp.html">GTK#</a> for its GUI.</li>
29
30         <li>Bugs with Mono or the data provider should be reported 
31         in Mono's Bugzilla <a href="http://bugzilla.ximian.com/">here</a>.  If you
32         do not have Bugzilla user account, it is free 
33         and easy to 
34         create one <a href="http://bugzilla.ximian.com/createaccount.cgi">here</a>.</li>
35                 
36 </ul>
37
38 ** Current Status
39
40 <ul>
41         <li>Able to connect, execute commands, and retrieve data...</li>
42         
43         <li>Works in mPhoto by providing access to a SQL Lite database to store images.</li>
44 </ul>
45
46 ** Action Plan
47
48 <ul>
49         <li>Create a DataAdapter for SQL Lite named SqliteDataAdapter that can be used to 
50         Fill a DataTable in a DataSet</li>
51         
52         <li>Get the method GetSchemaTable() in class SqliteDataReader to return a DataTable
53         that works</li>
54 </ul>
55
56 ** Testing
57
58 <ul>
59         <li>Have a working mcs and mono</li>
60         
61         <li>Make sure Mono.Data.SqliteClient.dll was built and is installed
62         in the same place as the mono class libraries.</li>
63         
64         <li>If you do not have <a href"http://www.hwaci.com/sw/sqlite/download.html">SQL Lite</a>,
65         download it.  There are binaries for Windows and Linux.</li>
66         
67         <li>There is a test named SqliteTest.cs found at mcs/class/Mono.Data.SqliteTest/Test</li>
68         
69         <li>Has a connection string format of "URI=file:some/path".  For example, 
70         the connection string "URI=file:SqliteTest.db" will use the database file 
71         named SqliteTest.db, if it does not exist, the file will be created.</li>
72         
73         <li>C# Example:
74 <pre>
75  using System;
76  using System.Data;
77  using Mono.Data.SqliteClient;
78  
79  public class Test 
80  {
81     public static void Main(string[] args)
82     {
83        string connectionString = "URI=file:SqliteTest.db";
84        IDbConnection dbcon;
85        dbcon = new SqliteConnection(connectionString);
86        dbcon.Open();
87        IDbCommand dbcmd = dbcon.CreateCommand();
88        // requires a table to be created named employee
89        // with columns firstname and lastname
90        // such as,
91        //        CREATE TABLE employee (
92        //           firstname varchar(32),
93        //           lastname varchar(32));
94        string sql = 
95           "SELECT firstname, lastname " + 
96           "FROM employee";
97        dbcmd.CommandText = sql;
98        IDataReader reader = dbcmd.ExecuteReader();
99        while(reader.Read()) {
100             string FirstName = (string) reader[0];
101             string LastName = (string) reader[1];
102             Console.WriteLine("Name: " + 
103                 FirstName + " " + LastName);
104        }
105        // clean up
106        reader.Close();
107        reader = null;
108        dbcmd.Dispose();
109        dbcmd = null;
110        dbcon.Close();
111        dbcon = null;
112     }
113  }
114 </pre>
115         </li>
116         <li>Building C# Example:
117         <ul>
118                 <li>Save the example to a file, such as, TestExample.cs</li>
119                 <li>Build on Linux:
120 <pre>
121         mcs TestExample.cs -r System.Data.dll \
122             -r Mono.Data.SqliteClient.dll
123 </pre>
124                 </li>
125                 <li>Build on Windows via Cygwin:
126 <pre>
127         mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
128              TestExample.cs \
129              -lib:C:/cygwin/home/MyHome/mono/install/lib \
130              -r System.Data.dll \
131              -r Mono.Data.SqliteClient.dll
132 </pre>
133                 </li>
134         </ul>
135         </li>
136         <li>Running the Example:
137 <pre>
138 mono TestExample.exe
139 </pre>
140         </li>
141
142 </ul>
143