/// <summary> /// 現在のLibraryDB向けのUPDATE文のプリペアドステートメントを生成する /// </summary> /// <param name="db">LibraryDB</param> /// <returns>UPDATE文のプリペアドステートメント</returns> private SQLite3DB.STMT GetUpdatePreparedStatement(SQLite3DB db) { string[] cols = GetToBeImportColumn().Select(_ => _.Name + " = ?").ToArray(); string updateFormat = "UPDATE list SET " + String.Join(",", cols) + " WHERE file_name = ?1;"; return(db.Prepare(updateFormat)); }
/// <summary> /// 現在のLibraryDB向けのINSERT文のプリペアドステートメントを生成する /// </summary> /// <param name="db">LibraryDB</param> /// <returns>INSERT文のプリペアドステートメント</returns> private SQLite3DB.STMT GetInsertPreparedStatement(SQLite3DB db) { string[] cols = GetToBeImportColumn().Select(_ => _.Name).ToArray(); string insertFormat = "INSERT INTO list ( " + String.Join(",", cols) + ") VALUES(" + String.Join(",", cols.Select(_ => "?").ToArray()) + ");"; return(db.Prepare(insertFormat)); }
/// <summary> /// 指定したファイル名のプレイリスト内でのIndexを取得 /// </summary> /// <param name="file_name">ファイル名</param> /// <returns>0から始まる位置。存在しない場合は-1。</returns> internal int GetIndexInPlaylist(string file_name) { try { var stmt = LibraryDB.Prepare("SELECT ROWID FROM " + PlaylistTableName + " WHERE file_name = ?;"); stmt.Bind(1, file_name); int ret = 0; stmt.Evaluate((o) => ret = int.Parse(o[0].ToString())); if (ret > 0) { return(ret - 1); } } catch (SQLite3DB.SQLite3Exception ex) { Logger.Debug(ex.ToString()); } return(-1); }
private void InitializeLibraryDB(SQLite3DB db, Column[] columns) { db.Exec(GetCreateLibraryDefinitionSchema()); using (var stmt = db.Prepare("INSERT INTO library_definition ( column_name, localized_name, type, is_primary, mapped_tag_field, is_text_search_target, omit_on_import) VALUES(?,?,?,?,?,?,?);")) { foreach (var col in columns) { stmt.Reset(); stmt.Bind(1, col.Name); stmt.Bind(2, col.LocalText); stmt.Bind(3, ((int)col.Type).ToString()); stmt.Bind(4, col.PrimaryKey ? "1" : "0"); stmt.Bind(5, col.MappedTagField == null ? "" : col.MappedTagField); stmt.Bind(6, col.IsTextSearchTarget ? "1" : "0"); stmt.Bind(7, col.OmitOnImport ? "1" : "0"); stmt.Evaluate(null); } } db.Exec(GetCreateSchema(columns)); db.Exec(GetCreateIndexSchema(columns)); }
public SQLite3DB.STMT PrepareForInsert() { SQLite3DB db = this.Connect(); return(db.Prepare("")); }