本文整理汇总了C++中SqliteDatabase类的典型用法代码示例。如果您正苦于以下问题:C++ SqliteDatabase类的具体用法?C++ SqliteDatabase怎么用?C++ SqliteDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SqliteDatabase类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SqliteDatabase
int Database_MorphGnt::get_id (const char * table_row, string item)
{
SqliteDatabase sql = SqliteDatabase (filename ());
// Two iterations to be sure a rowid can be returned.
for (unsigned int i = 0; i < 2; i++) {
// Check on the rowid and return it if it's there.
sql.clear ();
sql.add ("SELECT rowid FROM");
sql.add (table_row);
sql.add ("WHERE");
sql.add (table_row);
sql.add ("=");
sql.add (item);
sql.add (";");
vector <string> result = sql.query () ["rowid"];
if (!result.empty ()) return convert_to_int (result [0]);
// The rowid was not found: Insert the word into the table.
// The rowid will now be found during the second iteration.
sql.clear ();
sql.add ("INSERT INTO");
sql.add (table_row);
sql.add ("VALUES (");
sql.add (item);
sql.add (");");
sql.execute ();
}
return 0;
}
示例2: SqliteDatabase
void Database_Kjv::create ()
{
SqliteDatabase sql = SqliteDatabase (filename ());
sql.add ("DROP TABLE IF EXISTS kjv2;");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE kjv2 (book int, chapter int, verse int, strong int, english int);");
sql.execute ();
sql.clear ();
sql.add ("DROP TABLE IF EXISTS strong;");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS strong (strong text);");
sql.execute ();
sql.clear ();
sql.add ("DROP TABLE IF EXISTS english;");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS english (english text);");
sql.execute ();
sql.clear ();
sql.add ("VACUUM;");
sql.execute ();
}
示例3: md5
// Sets the login security tokens for a user.
// Also store whether the device is touch-enabled.
// It only writes to the table if the combination of username and tokens differs from what the table already contains.
void Database_Login::setTokens (string username, string address, string agent, string fingerprint, bool touch)
{
if (username == getUsername (address, agent, fingerprint)) return;
address = md5 (address);
agent = md5 (agent);
fingerprint = md5 (fingerprint);
SqliteDatabase sql (database ());
sql.add ("INSERT INTO logins (username, address, agent, fingerprint, touch, timestamp) VALUES (");
sql.add (username);
sql.add (",");
sql.add (address);
sql.add (",");
sql.add (agent);
sql.add (",");
sql.add (fingerprint);
sql.add (",");
sql.add (touch);
sql.add (",");
sql.add (timestamp ());
sql.add (");");
sql.execute ();
}
示例4: get_id
void Database_Kjv::store (int book, int chapter, int verse, string strong, string english)
{
int strongid = get_id ("strong", strong);
int englishid = get_id ("english", english);
SqliteDatabase sql = SqliteDatabase (filename ());
sql.add ("PRAGMA temp_store = MEMORY;");
sql.execute ();
sql.clear ();
sql.add ("PRAGMA synchronous = OFF;");
sql.execute ();
sql.clear ();
sql.add ("PRAGMA journal_mode = OFF;");
sql.execute ();
sql.clear ();
sql.add ("INSERT INTO kjv2 VALUES (");
sql.add (book);
sql.add (",");
sql.add (chapter);
sql.add (",");
sql.add (verse);
sql.add (",");
sql.add (strongid);
sql.add (",");
sql.add (englishid);
sql.add (");");
sql.execute ();
}
示例5: SqliteDatabase
void Database_HebrewLexicon::optimize ()
{
SqliteDatabase sql = SqliteDatabase (filename ());
sql.add ("VACUUM;");
sql.execute ();
}
示例6: sql
void Database_Login::testTimestamp ()
{
SqliteDatabase sql (database ());
sql.add ("UPDATE logins SET timestamp = timestamp - 370;");
sql.execute ();
}
示例7: sql
void Database_Privileges::getBible (string username, string bible, bool & read, bool & write)
{
SqliteDatabase sql (database ());
sql.add ("SELECT write FROM bibles WHERE username =");
sql.add (username);
sql.add ("AND bible =");
sql.add (bible);
sql.add (";");
vector <string> result = sql.query () ["write"];
read = (!result.empty());
sql.clear ();
sql.add ("SELECT write FROM bibles WHERE username =");
sql.add (username);
sql.add ("AND bible =");
sql.add (bible);
sql.add ("AND write;");
result = sql.query () ["write"];
write = (!result.empty());
}
示例8: removeBibleBook
// Give a privilege to a $username to access $bible to read it, or also to $write it.
void Database_Privileges::setBible (string username, string bible, bool write)
{
// First remove any entry.
removeBibleBook (username, bible, 0);
// Store the new entry.
SqliteDatabase sql (database ());
sql.add ("INSERT INTO bibles VALUES (");
sql.add (username);
sql.add (",");
sql.add (bible);
sql.add (",");
sql.add (0);
sql.add (",");
sql.add (write);
sql.add (");");
sql.execute ();
}
示例9: SqliteDatabase
void Database_MorphHb::create ()
{
SqliteDatabase sql = SqliteDatabase (filename ());
sql.add ("DROP TABLE IF EXISTS morphhb;");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE morphhb (book int, chapter int, verse int, parsing int, word int);");
sql.execute ();
sql.clear ();
sql.add ("DROP TABLE IF EXISTS parsing;");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS parsing (parsing text);");
sql.execute ();
sql.clear ();
sql.add ("DROP TABLE IF EXISTS word;");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS word (word text);");
sql.execute ();
}
示例10: get_id
void Database_MorphHb::store (int book, int chapter, int verse, string parsing, string word)
{
int parsing_id = get_id ("parsing", parsing);
int word_id = get_id ("word", word);
SqliteDatabase sql = SqliteDatabase (filename ());
sql.add ("PRAGMA temp_store = MEMORY;");
sql.execute ();
sql.clear ();
sql.add ("PRAGMA synchronous = OFF;");
sql.execute ();
sql.clear ();
sql.add ("PRAGMA journal_mode = OFF;");
sql.execute ();
sql.clear ();
sql.add ("INSERT INTO morphhb VALUES (");
sql.add (book);
sql.add (",");
sql.add (chapter);
sql.add (",");
sql.add (verse);
sql.add (",");
sql.add (parsing_id);
sql.add (",");
sql.add (word_id);
sql.add (");");
sql.execute ();
}
示例11: filter_url_unlink
void Database_MorphGnt::create ()
{
filter_url_unlink (database_sqlite_file (filename ()));
SqliteDatabase sql = SqliteDatabase (filename ());
sql.clear ();
sql.add ("CREATE TABLE morphgnt (book int, chapter int, verse int, pos int, parsing int, word int, lemma int);");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS pos (pos text);");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS parsing (parsing text);");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS word (word text);");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS lemma (lemma text);");
sql.execute ();
}
示例12: filter_url_unlink
void Database_HebrewLexicon::create ()
{
filter_url_unlink (database_sqlite_file (filename ()));
SqliteDatabase sql = SqliteDatabase (filename ());
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS aug (aug text, target text);");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS bdb (id text, definition text);");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS map (id text, bdb text);");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS pos (code text, name text);");
sql.execute ();
sql.clear ();
sql.add ("CREATE TABLE IF NOT EXISTS strong (strong text, definition text);");
sql.execute ();
}