SQLite Quick Start Guide

Source: Internet
Author: User
Tags sqlite tutorial

This is a few tutorials collected online.

1. Simple SQLite tutorial
Http://www.sqlite.com.cn/MySqlite/4/32.Html
2. SQLite getting started tutorial
Http://www.sqlite.com.cn/MySqlite/4/33.Html
3. SQLite official
Http://www.sqlite.org/
4. Recommended pysqlite User Guide
Http://gashero.yeax.com /? P = 13
5. pysqlite User Guide
Http://www.initd.org/pub/software/pysqlite/doc/usage-guide.html#brief-tutorial

 

If you are not patient with the aboveArticle, The following introduction can help you quickly get started:

1. DownloadHttp://www.sqlite.org/sqlite-3_6_22.zip

Decompress this ZIP file to the C: \ Windows Directory (in fact, it is also a file of sqlite3.exe)

2. Create a database

Enter the following command line:
Sqlite3.exe "C: \ test. DB"

That's simple! (Similar to db4o) If test. DB is not found on the hard disk, this command creates a database. if it already exists, the database is opened.

3. Find a graphical management tool: Visual SQLite, Official Website: http://www.visualsqlite.com/(but it seems not open, as we all know the reason...), Baidu or thunder a "visual SQLite" can find download, after the installation is similar to this:

4. Use SQLite in. net

First go to The http://sourceforge.net/projects/sqlite-dotnet2/files/ to download the. NET driver

Then you can use it. The following is a demonstrationCode:

Using system; using system. data. common; using system. data. SQLite; using system. diagnostics; using system. io; using system. windows. forms; namespace sqlitedemo {class program {static void main (string [] ARGs) {string _ dbfile = application. startuppath; _ dbfile = _ dbfile + "\ test. DB "; if (file. exists (_ dbfile) {file. delete (_ dbfile);} sqliteconnection. createfile (_ dbfile); dbproviderfactory factory = sqlit Efactory. instance; using (dbconnection conn = factory. createconnection () {// connect to the database Conn. connectionstring = "Data Source =" + _ dbfile; Conn. open (); // create a data table string SQL = "CREATE TABLE [person] ([ID] integer primary key, [name] varchar (50) Collate nocase )"; dbcommand cmd = Conn. createcommand (); cmd. connection = conn; cmd. commandtext = SQL; cmd. executenonquery (); // Add the CMD parameter. parameters. add (CMD. creat Eparameter (); // start timer stopwatch watch = new stopwatch (); watch. start (); dbtransaction trans = Conn. begintransaction (); // <------------------- try {// Insert 50 million records continuously for (INT I = 0; I <500000; I ++) {cmd. commandtext = "insert into [person] ([name]) values (?) "; Cmd. parameters [0]. value = I. tostring (); cmd. executenonquery ();} trans. commit (); // <-------------------} catch {TRANS. rollback (); // <------------------- throw; // <-------------------} // stop the timer watch. stop (); console. writeline (watch. elapsed); console. read ();}}}}

the result of running on my ThinkPad t61p is that a transaction is inserted into 50 million records, which takes about 3 seconds (test. DB is increased to about 7 MB ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.