本文整理汇总了C#中System.Data.SQLite.SQLiteConnection.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.ExecuteNonQuery方法的具体用法?C# SQLiteConnection.ExecuteNonQuery怎么用?C# SQLiteConnection.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.ExecuteNonQuery方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqliteStorage
public SqliteStorage(TableInfo table)
{
_file = Path.GetTempFileName();
_table = table;
_conn = new SQLiteConnection("Synchronous=Full;Data Source=" + _file);
_conn.Open();
string sql = String.Format("create table {0} ({1})", TABLE_NAME, ColumnsText);
_conn.ExecuteNonQuery(sql);
lock (_storageDirectory)
{
_storageDirectory[_file] = this;
}
}
示例2: downgrade_1_to_0
void downgrade_1_to_0(SQLiteConnection connection)
{
connection.ExecuteNonQuery(@"CREATE TABLE NewPeptideSpectrumMatch (Id INTEGER PRIMARY KEY, Spectrum INT, Analysis INT, Peptide INT, QValue NUMERIC, MonoisotopicMass NUMERIC, MolecularWeight NUMERIC, MonoisotopicMassError NUMERIC, MolecularWeightError NUMERIC, Rank INT, Charge INT);
INSERT INTO NewPeptideSpectrumMatch SELECT Id, Spectrum, Analysis, Peptide, QValue, ObservedNeutralMass, ObservedNeutralMass-MolecularWeightError, MonoisotopicMassError, MolecularWeightError, Rank, Charge FROM PeptideSpectrumMatch;
DROP TABLE PeptideSpectrumMatch;
ALTER TABLE NewPeptideSpectrumMatch RENAME TO PeptideSpectrumMatch;
DROP TABLE About;
");
}
示例3: downgrade_2_to_1
void downgrade_2_to_1(SQLiteConnection connection)
{
// add an empty ScanTimeInSeconds column
connection.ExecuteNonQuery(@"CREATE TABLE NewSpectrum (Id INTEGER PRIMARY KEY, Source INT, Index_ INT, NativeID TEXT, PrecursorMZ NUMERIC, ScanTimeInSeconds NUMERIC);
INSERT INTO NewSpectrum SELECT Id, Source, Index_, NativeID, PrecursorMZ, 0 FROM Spectrum;
DROP TABLE Spectrum;
ALTER TABLE NewSpectrum RENAME TO Spectrum;
UPDATE About SET SchemaRevision = 1;
");
}
示例4: downgrade_3_to_2
void downgrade_3_to_2(SQLiteConnection connection)
{
// delete quantitation tables and quantitative columns from SpectrumSource
connection.ExecuteNonQuery(@"DROP TABLE SpectrumQuantitation;
DROP TABLE DistinctMatchQuantitation;
DROP TABLE PeptideQuantitation;
DROP TABLE ProteinQuantitation;
CREATE TABLE TempSpectrumSource (Id INTEGER PRIMARY KEY, Name TEXT, URL TEXT, Group_ INT, MsDataBytes BLOB);
INSERT INTO TempSpectrumSource SELECT Id, Name, URL, Group_, MsDataBytes FROM SpectrumSource;
DROP TABLE SpectrumSource;
ALTER TABLE TempSpectrumSource RENAME TO SpectrumSource;
UPDATE About SET SchemaRevision = 2;
");
}
示例5: downgrade_4_to_3
void downgrade_4_to_3(SQLiteConnection connection)
{
// move MsDataBytes to SpectrumSource table and return to bugged INT key for DistinctMatchQuantitation
connection.ExecuteNonQuery(@"CREATE TABLE TempSpectrumSource (Id INTEGER PRIMARY KEY, Name TEXT, URL TEXT, Group_ INT, MsDataBytes BLOB, TotalSpectraMS1 INT, TotalIonCurrentMS1 NUMERIC, TotalSpectraMS2 INT, TotalIonCurrentMS2 NUMERIC, QuantitationMethod INT);
INSERT INTO TempSpectrumSource SELECT ss.Id, Name, URL, Group_, MsDataBytes, TotalSpectraMS1, TotalIonCurrentMS1, TotalSpectraMS2, TotalIonCurrentMS2, QuantitationMethod FROM SpectrumSource ss JOIN SpectrumSourceMetadata ssmd ON ss.Id=ssmd.Id;
DROP TABLE SpectrumSource;
ALTER TABLE TempSpectrumSource RENAME TO SpectrumSource;
DROP TABLE SpectrumSourceMetadata;
DROP TABLE DistinctMatchQuantitation;
CREATE TABLE DistinctMatchQuantitation (Id INTEGER PRIMARY KEY, iTRAQ_ReporterIonIntensities BLOB, TMT_ReporterIonIntensities BLOB, PrecursorIonIntensity NUMERIC);
UPDATE About SET SchemaRevision = 3;
");
}
示例6: downgrade_7_to_4
void downgrade_7_to_4(SQLiteConnection connection)
{
// just rename table; the extra columns will be ignored
connection.ExecuteNonQuery("ALTER TABLE FilterHistory RENAME TO FilteringCriteria");
}
示例7: downgrade_12_to_11
void downgrade_12_to_11(SQLiteConnection connection)
{
connection.ExecuteNonQuery(@"DROP TABLE XICMetrics;
CREATE TABLE XICMetrics (PsmId INTEGER PRIMARY KEY, PeakIntensity NUMERIC, PeakArea NUMERIC, PeakSNR NUMERIC, PeakTimeInSeconds NUMERIC);
INSERT INTO XICMetrics VALUES (1,0,0,0,0)");
}
示例8: IsValidFile
public static bool IsValidFile (string path)
{
try
{
string uncCompatiblePath = Util.GetSQLiteUncCompatiblePath(path);
using (var conn = new SQLiteConnection(String.Format("Data Source={0};Version=3", uncCompatiblePath)))
{
conn.Open();
// in a valid file, this will throw "already exists"
conn.ExecuteNonQuery("CREATE TABLE IntegerSet (Value INTEGER PRIMARY KEY)");
}
}
catch (SQLiteException e)
{
if (e.Message.Contains("already exists"))
return true;
}
// creating the table or any other exception indicates an invalid file
return false;
}
示例9: CreateFile
public static System.Data.IDbConnection CreateFile (string path)
{
lock (mutex)
if (newSession == null)
{
Configuration configuration = new Configuration()
.SetProperty("dialect", typeof(CustomSQLiteDialect).AssemblyQualifiedName)
.SetProperty("connection.connection_string", "Data Source=:memory:;Version=3;")
.SetProperty("connection.driver_class", typeof(NHibernate.Driver.SQLite20Driver).AssemblyQualifiedName)
.SetProperty("connection.provider", typeof(NHibernate.Connection.DriverConnectionProvider).AssemblyQualifiedName)
.SetProperty("connection.release_mode", "on_close")
;
ConfigureMappings(configuration);
var sessionFactory = configuration.BuildSessionFactory();
newSession = sessionFactory.OpenStatelessSession();
createSql = configuration.GenerateSchemaCreationScript(Dialect.GetDialect(configuration.Properties));
}
string uncCompatiblePath = Util.GetSQLiteUncCompatiblePath(path);
bool pooling = false;// path == ":memory:";
var conn = new SQLiteConnection(String.Format("Data Source={0};Version=3;{1}", uncCompatiblePath, (pooling ? "Pooling=True;Max Pool Size=1;" : "")));
conn.Open();
var journal_mode = conn.ExecuteQuery("PRAGMA journal_mode").Single()[0];
var synchronous = conn.ExecuteQuery("PRAGMA synchronous").Single()[0];
conn.ExecuteNonQuery(@"PRAGMA journal_mode=OFF;
PRAGMA synchronous=OFF;
PRAGMA automatic_indexing=OFF;
PRAGMA cache_size=30000;
PRAGMA temp_store=MEMORY;
PRAGMA page_size=32768;
PRAGMA mmap_size=70368744177664; -- 2^46");
var transaction = conn.BeginTransaction();
var cmd = conn.CreateCommand();
foreach (string sql in createSql)
cmd.ExecuteNonQuery(sql);
cmd.ExecuteNonQuery(String.Format("INSERT INTO About VALUES (1, 'IDPicker', '{0}', datetime('now'), {1})",
Util.Version, SchemaUpdater.CurrentSchemaRevision));
cmd.ExecuteNonQuery(@"CREATE TABLE PeptideSpectrumMatchScoreName (Id INTEGER PRIMARY KEY, Name TEXT UNIQUE NOT NULL);
CREATE TABLE DistinctMatchQuantitation (Id TEXT PRIMARY KEY, iTRAQ_ReporterIonIntensities BLOB, TMT_ReporterIonIntensities BLOB, PrecursorIonIntensity NUMERIC);
CREATE TABLE IntegerSet (Value INTEGER PRIMARY KEY);");
CreateIndexes(conn);
transaction.Commit();
conn.ExecuteNonQuery("PRAGMA journal_mode=" + journal_mode + ";" +
"PRAGMA synchronous=" + synchronous);
return conn;
}
示例10: CreateSessionFactory
public static ISessionFactory CreateSessionFactory (string path, SessionFactoryConfig config)
{
string uncCompatiblePath = Util.GetSQLiteUncCompatiblePath(path);
// update the existing database's schema if necessary, and if updated, recreate the indexes
if (path != ":memory:" &&
File.Exists(path) &&
IsValidFile(path) &&
SchemaUpdater.Update(path, null))
{
using (var conn = new SQLiteConnection(String.Format("Data Source={0};Version=3", uncCompatiblePath)))
{
conn.Open();
conn.ExecuteNonQuery(@"PRAGMA journal_mode=DELETE;
PRAGMA synchronous=OFF;
PRAGMA automatic_indexing=OFF;
PRAGMA cache_size=30000;
PRAGMA temp_store=MEMORY;
PRAGMA page_size=32768;
PRAGMA mmap_size=70368744177664; -- 2^46");
DropIndexes(conn);
CreateIndexes(conn);
}
}
bool pooling = path == ":memory:";
var configuration = new Configuration()
.SetProperty("show_sql", config.WriteSqlToConsoleOut ? "true" : "false")
.SetProperty("dialect", typeof(CustomSQLiteDialect).AssemblyQualifiedName)
.SetProperty("hibernate.cache.use_query_cache", "true")
//.SetProperty("adonet.batch_size", batchSize.ToString())
.SetProperty("connection.connection_string", String.Format("Data Source={0};Version=3;{1}", uncCompatiblePath, (pooling ? "Pooling=True;Max Pool Size=1;" : "")))
.SetProperty("connection.driver_class", typeof(NHibernate.Driver.SQLite20Driver).AssemblyQualifiedName)
.SetProperty("connection.provider", typeof(NHibernate.Connection.DriverConnectionProvider).AssemblyQualifiedName)
.SetProperty("connection.release_mode", "on_close")
;
ConfigureMappings(configuration);
if (config.UseUnfilteredTables)
{
configuration.ClassMappings.Single(o => o.Table.Name == "Protein").Table.Name = "UnfilteredProtein";
configuration.ClassMappings.Single(o => o.Table.Name == "Peptide").Table.Name = "UnfilteredPeptide";
configuration.ClassMappings.Single(o => o.Table.Name == "PeptideInstance").Table.Name = "UnfilteredPeptideInstance";
configuration.ClassMappings.Single(o => o.Table.Name == "PeptideSpectrumMatch").Table.Name = "UnfilteredPeptideSpectrumMatch";
configuration.ClassMappings.Single(o => o.Table.Name == "Spectrum").Table.Name = "UnfilteredSpectrum";
}
ISessionFactory sessionFactory = null;
lock(mutex)
sessionFactory = configuration.BuildSessionFactory();
sessionFactory.OpenStatelessSession().CreateSQLQuery(@"PRAGMA cache_size=10000;
PRAGMA temp_store=MEMORY;
PRAGMA page_size=32768;
PRAGMA mmap_size=70368744177664; -- 2^46").ExecuteUpdate();
if (config.CreateSchema)
CreateFile(path);
return sessionFactory;
}
示例11: GetConnection
private SQLiteConnection GetConnection()
{
SQLiteConnection conn = new SQLiteConnection(ConnectionString);
conn.Open();
conn.ExecuteNonQuery("PRAGMA synchronous = OFF;");
conn.ExecuteNonQuery("PRAGMA count_changes = OFF");
return conn;
}