C# Class Mono.Data.Sqlite.SqliteConnection

SQLite implentation of DbConnection.
The ConnectionString property of the SqliteConnection class can contain the following parameter(s), delimited with a semi-colon: Parameter Values Required Default Data Source {filename} Y Version 3 N 3 UseUTF16Encoding True
False
N False
DateTimeFormat Ticks - Use DateTime.Ticks
ISO8601 - Use ISO8601 DateTime format
N ISO8601
BinaryGUID True - Store GUID columns in binary form
False - Store GUID columns as text
N True
Cache Size {size in bytes} N 2000 Synchronous Normal - Normal file flushing behavior
Full - Full flushing after all writes
Off - Underlying OS flushes I/O's
N Normal
Page Size {size in bytes} N 1024 Password {password} N Enlist Y - Automatically enlist in distributed transactions
N - No automatic enlistment
N Y
Pooling True - Use connection pooling
False - Do not use connection pooling
N False
FailIfMissing True - Don't create the database if it does not exist, throw an error instead
False - Automatically create the database if it does not exist
N False
Max Page Count {size in pages} - Limits the maximum number of pages (limits the size) of the database N 0 Legacy Format True - Use the more compatible legacy 3.x database format
False - Use the newer 3.3x database format which compresses numbers more effectively
N False
Default Timeout {time in seconds}
The default command timeout
N 30
Journal Mode Delete - Delete the journal file after a commit
Persist - Zero out and leave the journal file on disk after a commit
Off - Disable the rollback journal entirely
N Delete
Read Only True - Open the database for read only access
False - Open the database for normal read/write access
N False
Max Pool Size The maximum number of connections for the given connection string that can be in the connection pool N 100 Default IsolationLevel The default transaciton isolation level N Serializable
Inheritance: System.Data.Common.DbConnection, ICloneable
Show file Open project: kumpera/mono Class Usage Examples

Private Properties

Property Type Description
BeginTransaction SqliteTransaction
BeginTransaction SqliteTransaction
CommitCallback int
CompressFile void
DecompressFile void
ExpandFileName string
FindKey string
MapMonoKeyword void
MapMonoUriPath string
MapUriPath string
OnStateChange void
ParseConnectionString string>.SortedList
RollbackCallback void
Schema_Catalogs System.Data.DataTable
Schema_Columns System.Data.DataTable
Schema_DataSourceInformation System.Data.DataTable
Schema_DataTypes System.Data.DataTable
Schema_ForeignKeys System.Data.DataTable
Schema_IndexColumns System.Data.DataTable
Schema_Indexes System.Data.DataTable
Schema_MetaDataCollections System.Data.DataTable
Schema_ReservedWords System.Data.DataTable
Schema_Tables System.Data.DataTable
Schema_Triggers System.Data.DataTable
Schema_ViewColumns System.Data.DataTable
Schema_Views System.Data.DataTable
UpdateCallback void

Public Methods

Method Description
BeginTransaction ( ) : SqliteTransaction

Creates a new SqliteTransaction if one isn't already active on the connection.

BeginTransaction ( IsolationLevel isolationLevel ) : SqliteTransaction

Creates a new SqliteTransaction if one isn't already active on the connection.

Unspecified will use the default isolation level specified in the connection string. If no isolation level is specified in the connection string, Serializable is used. Serializable transactions are the default. In this mode, the engine gets an immediate lock on the database, and no other threads may begin a transaction. Other threads may read from the database, but not write. With a ReadCommitted isolation level, locks are deferred and elevated as needed. It is possible for multiple threads to start a transaction in ReadCommitted mode, but if a thread attempts to commit a transaction while another thread has a ReadCommitted lock, it may timeout or cause a deadlock on both threads until both threads' CommandTimeout's are reached.

ChangeDatabase ( string databaseName ) : void

Not implemented

ChangePassword ( byte newPassword ) : void

Change the password (or assign a password) to an open database.

No readers or writers may be active for this process. The database must already be open and if it already was password protected, the existing password must already have been supplied.

ChangePassword ( string newPassword ) : void

Change the password (or assign a password) to an open database.

No readers or writers may be active for this process. The database must already be open and if it already was password protected, the existing password must already have been supplied.

ClearAllPools ( ) : void

Clears all connection pools. Any active connections will be discarded instead of sent to the pool when they are closed.

ClearPool ( SqliteConnection connection ) : void

Clears the connection pool associated with the connection. Any other active connections using the same database file will be discarded instead of returned to the pool when they are closed.

Clone ( ) : object

Creates a clone of the connection. All attached databases and user-defined functions are cloned. If the existing connection is open, the cloned connection will also be opened.

Close ( ) : void

When the database connection is closed, all commands linked to this connection are automatically reset.

CreateCommand ( ) : SqliteCommand

Create a new SqliteCommand and associate it with this connection.

CreateFile ( string databaseFileName ) : void

Creates a database file. This just creates a zero-byte file which SQLite will turn into a database when the file is opened properly.

EnlistTransaction ( System transaction ) : void

Manual distributed transaction enlistment support

GetSchema ( ) : DataTable

Returns the MetaDataCollections schema

GetSchema ( string collectionName ) : DataTable

Returns schema information of the specified collection

GetSchema ( string collectionName, string restrictionValues ) : DataTable

Retrieves schema information using the specified constraint(s) for the specified collection

Open ( ) : void

Opens the connection using the parameters found in the ConnectionString

SetPassword ( byte databasePassword ) : void

Sets the password for a password-protected database. A password-protected database is unusable for any operation until the password has been set.

SetPassword ( string databasePassword ) : void

Sets the password for a password-protected database. A password-protected database is unusable for any operation until the password has been set.

SqliteConnection ( ) : System

Default constructor

SqliteConnection ( SqliteConnection connection ) : System

Clones the settings and connection string from an existing connection. If the existing connection is already open, this function will open its own connection, enumerate any attached databases of the original connection, and automatically attach to them.

SqliteConnection ( string connectionString ) : System

Initializes the connection with the specified connection string

Protected Methods

Method Description
BeginDbTransaction ( IsolationLevel isolationLevel ) : DbTransaction

Forwards to the local BeginTransaction() function

CreateDbCommand ( ) : DbCommand

Forwards to the local CreateCommand() function

Dispose ( bool disposing ) : void

Disposes of the SqliteConnection, closing it if it is active.

Private Methods

Method Description
BeginTransaction ( IsolationLevel isolationLevel, bool deferredLock ) : SqliteTransaction
BeginTransaction ( bool deferredLock ) : SqliteTransaction
CommitCallback ( IntPtr parg ) : int
CompressFile ( string databaseFileName ) : void
DecompressFile ( string databaseFileName ) : void
ExpandFileName ( string sourceFile ) : string

Expand the filename of the data source, resolving the |DataDirectory| macro as appropriate.

FindKey ( string>.SortedList items, string key, string defValue ) : string

Looks for a key in the array of key/values of the parameter string. If not found, return the specified default value

MapMonoKeyword ( string arPiece, string>.SortedList ls ) : void

Maps mono-specific connection string keywords to the standard ones

MapMonoUriPath ( string path ) : string
MapUriPath ( string path ) : string
OnStateChange ( ConnectionState newState ) : void

Raises the state change event when the state of the connection changes

ParseConnectionString ( string connectionString ) : string>.SortedList

Parses the connection string into component parts

RollbackCallback ( IntPtr parg ) : void
Schema_Catalogs ( string strCatalog ) : DataTable

Retrieves catalog (attached databases) schema information for the database

Schema_Columns ( string strCatalog, string strTable, string strColumn ) : DataTable

Build a Columns schema

Schema_DataSourceInformation ( ) : DataTable

Builds a DataSourceInformation datatable

Schema_DataTypes ( ) : DataTable
Schema_ForeignKeys ( string strCatalog, string strTable, string strKeyName ) : DataTable

Retrieves foreign key information from the specified set of filters

Schema_IndexColumns ( string strCatalog, string strTable, string strIndex, string strColumn ) : DataTable

Returns the base column information for indexes in a database

Schema_Indexes ( string strCatalog, string strTable, string strIndex ) : DataTable

Returns index information for the given database and catalog

Schema_MetaDataCollections ( ) : DataTable

Builds a MetaDataCollections schema datatable

Schema_ReservedWords ( ) : DataTable
Schema_Tables ( string strCatalog, string strTable, string strType ) : DataTable

Retrieves table schema information for the database and catalog

Schema_Triggers ( string catalog, string table, string triggerName ) : DataTable
Schema_ViewColumns ( string strCatalog, string strView, string strColumn ) : DataTable

Returns detailed column information for a specified view

Schema_Views ( string strCatalog, string strView ) : DataTable

Retrieves view schema information for the database

UpdateCallback ( IntPtr puser, int type, IntPtr database, IntPtr table, System.Int64 rowid ) : void

Method Details

BeginDbTransaction() protected method

Forwards to the local BeginTransaction() function
protected BeginDbTransaction ( IsolationLevel isolationLevel ) : DbTransaction
isolationLevel IsolationLevel Supported isolation levels are Unspecified, Serializable, and ReadCommitted
return System.Data.Common.DbTransaction

BeginTransaction() public method

Creates a new SqliteTransaction if one isn't already active on the connection.
public BeginTransaction ( ) : SqliteTransaction
return SqliteTransaction

BeginTransaction() public method

Creates a new SqliteTransaction if one isn't already active on the connection.
Unspecified will use the default isolation level specified in the connection string. If no isolation level is specified in the connection string, Serializable is used. Serializable transactions are the default. In this mode, the engine gets an immediate lock on the database, and no other threads may begin a transaction. Other threads may read from the database, but not write. With a ReadCommitted isolation level, locks are deferred and elevated as needed. It is possible for multiple threads to start a transaction in ReadCommitted mode, but if a thread attempts to commit a transaction while another thread has a ReadCommitted lock, it may timeout or cause a deadlock on both threads until both threads' CommandTimeout's are reached.
public BeginTransaction ( IsolationLevel isolationLevel ) : SqliteTransaction
isolationLevel IsolationLevel Supported isolation levels are Serializable, ReadCommitted and Unspecified.
return SqliteTransaction

ChangeDatabase() public method

Not implemented
public ChangeDatabase ( string databaseName ) : void
databaseName string
return void

ChangePassword() public method

Change the password (or assign a password) to an open database.
No readers or writers may be active for this process. The database must already be open and if it already was password protected, the existing password must already have been supplied.
public ChangePassword ( byte newPassword ) : void
newPassword byte The new password to assign to the database
return void

ChangePassword() public method

Change the password (or assign a password) to an open database.
No readers or writers may be active for this process. The database must already be open and if it already was password protected, the existing password must already have been supplied.
public ChangePassword ( string newPassword ) : void
newPassword string The new password to assign to the database
return void

ClearAllPools() public static method

Clears all connection pools. Any active connections will be discarded instead of sent to the pool when they are closed.
public static ClearAllPools ( ) : void
return void

ClearPool() public static method

Clears the connection pool associated with the connection. Any other active connections using the same database file will be discarded instead of returned to the pool when they are closed.
public static ClearPool ( SqliteConnection connection ) : void
connection SqliteConnection
return void

Clone() public method

Creates a clone of the connection. All attached databases and user-defined functions are cloned. If the existing connection is open, the cloned connection will also be opened.
public Clone ( ) : object
return object

Close() public method

When the database connection is closed, all commands linked to this connection are automatically reset.
public Close ( ) : void
return void

CreateCommand() public method

Create a new SqliteCommand and associate it with this connection.
public CreateCommand ( ) : SqliteCommand
return SqliteCommand

CreateDbCommand() protected method

Forwards to the local CreateCommand() function
protected CreateDbCommand ( ) : DbCommand
return System.Data.Common.DbCommand

CreateFile() static public method

Creates a database file. This just creates a zero-byte file which SQLite will turn into a database when the file is opened properly.
static public CreateFile ( string databaseFileName ) : void
databaseFileName string The file to create
return void

Dispose() protected method

Disposes of the SqliteConnection, closing it if it is active.
protected Dispose ( bool disposing ) : void
disposing bool True if the connection is being explicitly closed.
return void

EnlistTransaction() public method

Manual distributed transaction enlistment support
public EnlistTransaction ( System transaction ) : void
transaction System The distributed transaction to enlist in
return void

GetSchema() public method

Returns the MetaDataCollections schema
public GetSchema ( ) : DataTable
return System.Data.DataTable

GetSchema() public method

Returns schema information of the specified collection
public GetSchema ( string collectionName ) : DataTable
collectionName string The schema collection to retrieve
return System.Data.DataTable

GetSchema() public method

Retrieves schema information using the specified constraint(s) for the specified collection
public GetSchema ( string collectionName, string restrictionValues ) : DataTable
collectionName string The collection to retrieve
restrictionValues string The restrictions to impose
return System.Data.DataTable

Open() public method

Opens the connection using the parameters found in the ConnectionString
public Open ( ) : void
return void

SetPassword() public method

Sets the password for a password-protected database. A password-protected database is unusable for any operation until the password has been set.
public SetPassword ( byte databasePassword ) : void
databasePassword byte The password for the database
return void

SetPassword() public method

Sets the password for a password-protected database. A password-protected database is unusable for any operation until the password has been set.
public SetPassword ( string databasePassword ) : void
databasePassword string The password for the database
return void

SqliteConnection() public method

Default constructor
public SqliteConnection ( ) : System
return System

SqliteConnection() public method

Clones the settings and connection string from an existing connection. If the existing connection is already open, this function will open its own connection, enumerate any attached databases of the original connection, and automatically attach to them.
public SqliteConnection ( SqliteConnection connection ) : System
connection SqliteConnection
return System

SqliteConnection() public method

Initializes the connection with the specified connection string
public SqliteConnection ( string connectionString ) : System
connectionString string The connection string to use on the connection
return System