public RollStore (QueuedSqliteDatabase database, bool is_new) : base (database, false) { if (!is_new && Database.TableExists("rolls")) return; Database.ExecuteNonQuery ( "CREATE TABLE rolls ( " + " id INTEGER PRIMARY KEY NOT NULL, " + " time INTEGER NOT NULL " + ")"); }
public FaceStore (QueuedSqliteDatabase database, bool is_new) : base (database, false) { if (!is_new && Database.TableExists("faces")) return; Database.ExecuteNonQuery ( "CREATE TABLE faces ( " + " id INTEGER PRIMARY KEY NOT NULL, " + " photo_id INTEGER NOT NULL, " + " tag_id INTEGER NOT NULL, " + " x INTEGER NOT NULL, " + " y INTEGER NOT NULL, " + " width INTEGER NOT NULL, " + " height INTEGER NOT NULL " + ")"); }
// Constructor public TagStore(QueuedSqliteDatabase database, bool is_new) : base(database, true) { // The label for the root category is used in new and edit tag dialogs root_category = new Category(null, 0, Catalog.GetString("(None)")); if (!is_new) { LoadAllTags(); } else { CreateTable(); CreateDefaultTags(); } }
// Constructor public PhotoStore(QueuedSqliteDatabase database, bool is_new) : base(database, false) { EnsureThumbnailDirectory(); if (!is_new) { return; } Database.ExecuteNonQuery( //WARNING: if you change this schema, reflect your changes //to Updater.cs, at revision 7.0 "CREATE TABLE photos ( " + " id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "+ " time INTEGER NOT NULL, "+ " uri STRING NOT NULL, "+ " description TEXT NOT NULL, "+ " roll_id INTEGER NOT NULL, "+ " default_version_id INTEGER NOT NULL, "+ " rating INTEGER NULL, "+ " md5_sum TEXT NULL "+ ")"); Database.ExecuteNonQuery( "CREATE TABLE photo_tags ( " + " photo_id INTEGER, "+ " tag_id INTEGER, " + " UNIQUE (photo_id, tag_id) " + ")"); Database.ExecuteNonQuery( "CREATE TABLE photo_versions ( "+ " photo_id INTEGER, "+ " version_id INTEGER, "+ " name STRING, "+ " uri STRING NOT NULL,"+ " md5_sum STRING NOT NULL,"+ " protected BOOLEAN, "+ " UNIQUE (photo_id, version_id) "+ ")"); Database.ExecuteNonQuery("CREATE INDEX idx_photo_versions_id ON photo_versions(photo_id)"); Database.ExecuteNonQuery("CREATE INDEX idx_photos_roll_id ON photos(roll_id)"); }
private void SqliteUpgrade() { //Close the db database.Dispose(); string upgrader_path = null; string [] possible_paths = { Path.Combine(Defines.BINDIR, "f-spot-sqlite-upgrade"), "../tools/f-spot-sqlite-upgrade", "/usr/local/bin/f-spot-sqlite-upgrade", "/usr/bin/f-spot-sqlite-upgrade", }; foreach (string p in possible_paths) { if (File.Exists(p)) { upgrader_path = p; break; } } if (upgrader_path == null) { throw new DbException("Failed to upgrade the f-spot sqlite2 database to sqlite3!\n" + "Unable to find the f-spot-sqlite-upgrade script on your system"); } Console.WriteLine("Running {0}...", upgrader_path); ProcessStartInfo updaterInfo = new ProcessStartInfo(upgrader_path); updaterInfo.UseShellExecute = false; updaterInfo.RedirectStandardError = true; Process updater = Process.Start(updaterInfo); string stdError = updater.StandardError.ReadToEnd(); updater.WaitForExit(); if (updater.ExitCode != 0) { throw new DbException("Failed to upgrade the f-spot sqlite2 database to sqlite3!\n" + stdError); } //Re-open the db database = new QueuedSqliteDatabase(path); }
public FaceStore(QueuedSqliteDatabase database, bool is_new) : base(database, false) { if (!is_new && Database.TableExists("faces")) { return; } Database.ExecuteNonQuery( "CREATE TABLE faces ( " + " id INTEGER PRIMARY KEY NOT NULL, "+ " photo_id INTEGER NOT NULL, "+ " tag_id INTEGER NOT NULL, " + " x INTEGER NOT NULL, "+ " y INTEGER NOT NULL, " + " width INTEGER NOT NULL, " + " height INTEGER NOT NULL " + ")"); }
public PhotoStoreAddOn(QueuedSqliteDatabase database) { //Log.Debug("Try to Alter PhotoVersion"); this.Database = database; try{ //SqliteDataReader reader = Database.Query ( new DbCommand ("SELECT is_auto_detected FROM photo_versions ")); } catch(Exception ex){ Log.Debug("Try Alter Table Failed"); Log.Exception(ex); Database.ExecuteNonQuery( new DbCommand("ALTER TABLE photo_versions ADD is_auto_detected BOOLEAN NOT NULL DEFAULT 0") ); } }
public void Init(string path, bool create_if_missing) { uint timer = Log.DebugTimerStart(); bool new_db = !File.Exists(path); this.path = path; if (new_db && !create_if_missing) { throw new Exception(path + ": File not found"); } database = new QueuedSqliteDatabase(path); database.ExceptionThrown += HandleDbException; if (database.GetFileVersion(path) == 2) { SqliteUpgrade(); } // Load or create the meta table meta_store = new MetaStore(Database, new_db); // Update the database schema if necessary FSpot.Database.Updater.Run(this); Database.BeginTransaction(); tag_store = new TagStore(Database, new_db); roll_store = new RollStore(Database, new_db); export_store = new ExportStore(Database, new_db); job_store = new JobStore(Database, new_db); photo_store = new PhotoStore(Database, new_db); Database.CommitTransaction(); empty = new_db; Log.DebugTimerPrint(timer, "Db Initialization took {0}"); }
// Constructor public PhotoStore(QueuedSqliteDatabase database, bool is_new) : base(database, false) { EnsureThumbnailDirectory(); if (!is_new) { return; } Database.ExecuteNonQuery( "CREATE TABLE photos ( " + " id INTEGER PRIMARY KEY NOT NULL, "+ " time INTEGER NOT NULL, "+ " directory_path STRING NOT NULL, "+ " name STRING NOT NULL, "+ " description TEXT NOT NULL, "+ " roll_id INTEGER NOT NULL, "+ " default_version_id INTEGER NOT NULL "+ ")"); Database.ExecuteNonQuery( "CREATE TABLE photo_tags ( " + " photo_id INTEGER, "+ " tag_id INTEGER " + ")"); Database.ExecuteNonQuery( "CREATE TABLE photo_versions ( " + " photo_id INTEGER, " + " version_id INTEGER, " + " name STRING " + ")"); }
// Constructor public TagStore (QueuedSqliteDatabase database, bool is_new) : base (database, true) { // The label for the root category is used in new and edit tag dialogs root_category = new Category (null, 0, Catalog.GetString ("(None)")); if (! is_new) { LoadAllTags (); } else { CreateTable (); CreateDefaultTags (); } }
// Constructor. public DbStore (QueuedSqliteDatabase database, bool cache_is_immortal) { this.database = database; this.cache_is_immortal = cache_is_immortal; item_cache = new Hashtable (); }
// Constructor public ExportStore (QueuedSqliteDatabase database, bool is_new) : base (database, true) { if (is_new || !Database.TableExists ("exports")) CreateTable (); else LoadAllItems (); }
public JobStore (QueuedSqliteDatabase database, bool is_new) : base (database, true) { if (is_new || !Database.TableExists ("jobs")) { CreateTable (); } else { LoadAllItems (); } }
public void Init (string path, bool create_if_missing) { bool new_db = ! File.Exists (path); this.path = path; if (new_db && ! create_if_missing) throw new Exception (path + ": File not found"); database = new QueuedSqliteDatabase(path); // Load or create the meta table meta_store = new MetaStore (Database, new_db); // Update the database schema if necessary FSpot.Database.Updater.Run (this); Database.BeginTransaction (); face_store = new FaceStore (Database, new_db); tag_store = new TagStore (Database, new_db); roll_store = new RollStore (Database, new_db); export_store = new ExportStore (Database, new_db); job_store = new JobStore (Database, new_db); photo_store = new PhotoStore (Database, new_db); Database.CommitTransaction (); empty = new_db; }
private void SqliteUpgrade () { //Close the db database.Dispose(); string upgrader_path = null; string [] possible_paths = { Path.Combine (Defines.BINDIR, "f-spot-sqlite-upgrade"), "../tools/f-spot-sqlite-upgrade", "/usr/local/bin/f-spot-sqlite-upgrade", "/usr/bin/f-spot-sqlite-upgrade", }; foreach (string p in possible_paths) if (File.Exists (p)) { upgrader_path = p; break; } if (upgrader_path == null) throw new DbException ("Failed to upgrade the f-spot sqlite2 database to sqlite3!\n" + "Unable to find the f-spot-sqlite-upgrade script on your system"); Console.WriteLine ("Running {0}...", upgrader_path); ProcessStartInfo updaterInfo = new ProcessStartInfo (upgrader_path); updaterInfo.UseShellExecute = false; updaterInfo.RedirectStandardError = true; Process updater = Process.Start (updaterInfo); string stdError = updater.StandardError.ReadToEnd (); updater.WaitForExit (); if (updater.ExitCode != 0) throw new DbException("Failed to upgrade the f-spot sqlite2 database to sqlite3!\n" + stdError); //Re-open the db database = new QueuedSqliteDatabase(path); }
// Constructor public MetaStore (QueuedSqliteDatabase database, bool is_new) : base (database, true) { if (is_new || !Database.TableExists ("meta")) { CreateTable (); CreateDefaultItems (is_new); } else LoadAllItems (); }
// Constructor public PhotoStore (QueuedSqliteDatabase database, bool is_new) : base (database, false) { EnsureThumbnailDirectory (); if (! is_new) return; Database.ExecuteNonQuery ( "CREATE TABLE photos ( " + " id INTEGER PRIMARY KEY NOT NULL, " + " time INTEGER NOT NULL, " + " directory_path STRING NOT NULL, " + " name STRING NOT NULL, " + " description TEXT NOT NULL, " + " roll_id INTEGER NOT NULL, " + " default_version_id INTEGER NOT NULL " + ")"); Database.ExecuteNonQuery ( "CREATE TABLE photo_tags ( " + " photo_id INTEGER, " + " tag_id INTEGER " + ")"); Database.ExecuteNonQuery ( "CREATE TABLE photo_versions ( " + " photo_id INTEGER, " + " version_id INTEGER, " + " name STRING " + ")"); }
// Constructor public PhotoStore (QueuedSqliteDatabase database, bool is_new) : base (database, false) { EnsureThumbnailDirectory (); if (! is_new) return; Database.ExecuteNonQuery ( //WARNING: if you change this schema, reflect your changes //to Updater.cs, at revision 7.0 "CREATE TABLE photos ( " + " id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + " time INTEGER NOT NULL, " + " uri STRING NOT NULL, " + " description TEXT NOT NULL, " + " roll_id INTEGER NOT NULL, " + " default_version_id INTEGER NOT NULL, " + " rating INTEGER NULL, " + " md5_sum TEXT NULL " + ")"); Database.ExecuteNonQuery ( "CREATE TABLE photo_tags ( " + " photo_id INTEGER, " + " tag_id INTEGER, " + " UNIQUE (photo_id, tag_id) " + ")"); Database.ExecuteNonQuery ( "CREATE TABLE photo_versions ( "+ " photo_id INTEGER, " + " version_id INTEGER, " + " name STRING, " + " uri STRING NOT NULL," + " md5_sum STRING NOT NULL," + " protected BOOLEAN, " + " UNIQUE (photo_id, version_id) " + ")"); Database.ExecuteNonQuery ("CREATE INDEX idx_photo_versions_id ON photo_versions(photo_id)"); Database.ExecuteNonQuery ("CREATE INDEX idx_photos_roll_id ON photos(roll_id)"); }
public void Init (string path, bool create_if_missing) { uint timer = Log.DebugTimerStart (); bool new_db = ! File.Exists (path); this.path = path; if (new_db && ! create_if_missing) throw new Exception (path + ": File not found"); database = new QueuedSqliteDatabase(path); database.ExceptionThrown += HandleDbException; if (database.GetFileVersion(path) == 2) SqliteUpgrade (); // Load or create the meta table meta_store = new MetaStore (Database, new_db); // Update the database schema if necessary FSpot.Database.Updater.Run (this); Database.BeginTransaction (); tag_store = new TagStore (Database, new_db); roll_store = new RollStore (Database, new_db); export_store = new ExportStore (Database, new_db); job_store = new JobStore (Database, new_db); photo_store = new PhotoStore (Database, new_db); Database.CommitTransaction (); empty = new_db; Log.DebugTimerPrint (timer, "Db Initialization took {0}"); }