SQLite database connection method

Source: Internet
Author: User
SQLite database connection method

 

SQLite. net

Type:. NET Framework class library

Usage: system. Data. SQLite. sqliteconnection

Basic

Data Source = filename; version = 3;

Version 2 is not supported by this class library.

Using UTF16

Data Source = filename; version = 3; useutf16encoding = true;

With Password

Data Source = filename; version = 3; Password = mypassword;

Using the pre 3.3x database format

Data Source = filename; version = 3; legacy format = true;

With Connection Pooling

Connection pooling is not enabled by default. Use the following parameters to control the Connection Pooling mechanic.

Data Source = filename; version = 3; pooling = false; Max pool size = 100;

Read Only Connection

Data Source = filename; version = 3; read only = true;

 

Using datetime. ticks as datetime format

Data Source = filename; version = 3; datetimeformat = ticks;

The default value is iso8601 which activates the use of the iso8601 datetime format

 

Store guid as text

Normally, guids are stored in a binary format. Use this connection string to store guids as text.

Data Source = filename; version = 3; binaryguid = false;

Note that storing guids as text uses more space in the database.

 

Specify cache size

Data Source = filename; version = 3; cache size = 2000;

The cache size value measured in bytes

 

Specify page size

Data Source = filename; version = 2; page size = 1024;

The page size value measured in bytes

 

Disable enlistment in distributed transactions

Data Source = filename; version = 3; enlist = N;

 

Disable enlistment in distributed transactions

Data Source = filename; version = 3; enlist = N;

 

Disable create database behaviour

If
The database file doesn't exist, the default behaviour is to create
New file. Use the following parameter to raise an error instead
Creating a new database file.

Data Source = filename; version = 3; failifmissing = true;

Limit the size of Database

Data Source = filename; version = 3; Max page count = 5000;

The max page count is measured in pages. This parameter limits the maximum number of pages of the database.

 

Disable the Journal File

This one disables the rollback journal entirely.

Data Source = filename; version = 3; Journal mode = off;

 

Persist the Journal File

This one blanks and leaves the Journal File on disk after a commit. Default behaviour is to delete the journal file after each commit.

Data Source = filename; version = 3; Journal mode = persist;

 

Controling file Flushing

Data Source = filename; version = 3; synchronous = full;

Full specifies a full flush to take action after each write. Normal is the default value. off means that the underlying OS flushes I/O's.

2. finsar. SQLite ADO. NET data provider

Standard

Data Source = mydb. DB; version = 3;

The "version" key can take value "2" for SQLite 2.x (default) or value "3" for SQLite 3.x

Create a new database

Data Source = mydb. DB; version = 3; new = true;

Using Compression

Data Source = mydb. DB; version = 3; compress = true;

Specifying cache size

The cache size value represents the amount of data
Pages that are held in memory. Try increase this value for speed
Improvements but don't forget to keep track of the applications memory
Usage.

Data Source = mydb. DB; version = 3; cache size = 3000;

 

3. sqlite3 ODBC driver

Standard

Driver = sqlite3 ODBC driver; database = mydb. DB; longnames = 0; timeout = 1000; notxn = 0; syncpragma = normal; stepapi = 0;

 

. NET Framework data provider for ODBC

Bridging to sqlite3 ODBC driver

This is just one
Connection string sample for the wrapping odbcconnection class that
Callthe underlying ODBC driver. See respective ODBC driver for more
Connection strings to use with this class.

Driver = sqlite3 ODBC driver; database = mydb. DB; longnames = 0; timeout = 1000; notxn = 0; syncpragma = normal; stepapi = 0;

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.