public void CreateTable() { if (myDB.ExistsTable(Name)) { return; } ValidationResult result = Schema.Validate(); if (result != ValidationResult.None) { throw new ArgumentException("invalid table description: " + result); } StringBuilder sb = new StringBuilder(); sb.Append("CREATE TABLE "); sb.Append(Schema.Name); sb.Append(" ( "); var last = Schema.Columns.Last(); foreach (var column in Schema.Columns) { sb.Append(column.ColumnName); sb.Append(" "); sb.Append(myDB.GetDBType(column.DataType)); if (column.ColumnName == Schema.IdColumn) { sb.Append(" PRIMARY KEY AUTOINCREMENT"); } else { sb.Append((column.AllowDBNull ? " NULL" : " NOT NULL")); } if (column != last) { sb.Append(","); } } sb.Append(");"); myDB.Execute(sb.ToString()); }
public void Execute( IDatabaseSC db ) { if ( db.ExistsTable( TableName ) ) { myLogger.Debug( "Table {0} already exists. Skipping", TableName ); return; } myLogger.Debug( "Creating table {0}", TableName ); db.Execute( CreateCmd ); }
public void Execute(IDatabaseSC db) { if (db.ExistsTable(TableName)) { myLogger.Debug("Table {0} already exists. Skipping", TableName); return; } myLogger.Debug("Creating table {0}", TableName); db.Execute(CreateCmd); }
private void InsertKey(IDatabaseSC db) { var cmd = string.Format("INSERT INTO db_metadata VALUES ( '{0}', '{1}' );", Key, Value); db.Execute(cmd); }
private void DeleteKey(IDatabaseSC db) { var cmd = string.Format("DELETE FROM db_metadata where key == '{0}';", Key); db.Execute(cmd); }
public void Rollback(IDatabaseSC db) { db.Execute(RollbackCmd); }
public void Execute(IDatabaseSC db) { db.Execute(UpdateCmd); }
public void Rollback( IDatabaseSC db ) { myLogger.Debug( "Dropping table {0}", TableName ); db.Execute( "drop table " + TableName ); }
public void Rollback(IDatabaseSC db) { myLogger.Debug("Dropping table {0}", TableName); db.Execute("drop table " + TableName); }
public void Rollback( IDatabaseSC db ) { db.Execute( RollbackCmd ); }
public void Execute( IDatabaseSC db ) { db.Execute( UpdateCmd ); }
private void InsertKey( IDatabaseSC db ) { var cmd = string.Format( "INSERT INTO db_metadata VALUES ( '{0}', '{1}' );", Key, Value ); db.Execute( cmd ); }
private void DeleteKey( IDatabaseSC db ) { var cmd = string.Format( "DELETE FROM db_metadata where key == '{0}';", Key ); db.Execute( cmd ); }