sqlite 4.4 KB

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