sqlite

sqlite filter by day of the week in one statement

為{幸葍}努か 提交于 2020-01-24 01:20:27
问题 I would like to filter by day of the week (Thursday in my example) in one statement. The next statement works (please note that date is a column name): SELECT CAST (strftime('%w', date) AS Integer) = 4 FROM sales WHERE id=123; However, when I include the above filter I get no results: SELECT * FROM sales WHERE id=123 AND (SELECT CAST (strftime('%w', date) AS Integer) = 4 FROM sales WHERE id=123) = 1; 回答1: Although I do not know why the previous code doesn't work I post an alternative working

SQLite concurrency: the 2nd process doesn't get DB updates

孤人 提交于 2020-01-24 00:32:48
问题 In order to see if SQLite can be used by 2 processes at the same time, I tried this: script1.py (updating the database every 1 second) import sqlite3, time conn = sqlite3.connect('test.db') conn.execute("CREATE TABLE IF NOT EXISTS kv (key text, value text)") for i in range(1000): conn.execute('REPLACE INTO kv (key, value) VALUES (?,?)', (1, i)) conn.commit() print i time.sleep(1) script2.py (querying the database every 1 second) import sqlite3, time conn = sqlite3.connect('test.db') c = conn

SQLite concurrency: the 2nd process doesn't get DB updates

扶醉桌前 提交于 2020-01-24 00:32:01
问题 In order to see if SQLite can be used by 2 processes at the same time, I tried this: script1.py (updating the database every 1 second) import sqlite3, time conn = sqlite3.connect('test.db') conn.execute("CREATE TABLE IF NOT EXISTS kv (key text, value text)") for i in range(1000): conn.execute('REPLACE INTO kv (key, value) VALUES (?,?)', (1, i)) conn.commit() print i time.sleep(1) script2.py (querying the database every 1 second) import sqlite3, time conn = sqlite3.connect('test.db') c = conn

Saving an image on sqlite from camera or gallery

给你一囗甜甜゛ 提交于 2020-01-24 00:18:05
问题 I am struggling with saving image on sqlite. I am trying to save image as blob on sqlite. I don't know how to declare imageView to byte[] because I am using insert method on dbAdapter . Is it good way to save the image into database? some people said that saving file path url into database is better. If it is better, please give me some your hands. I am really getting tough for that. Many thanks. protected void onActivityResult(int requestCode, int resultCode, Intent data) { super

SQLite fuzzy duplicate search using LIKE

蹲街弑〆低调 提交于 2020-01-23 21:28:28
问题 I have a table with 4 entries. CREATE TABLE tab( name Text ); INSERT INTO "tab" VALUES('Intertek'); INSERT INTO "tab" VALUES('Pntertek'); INSERT INTO "tab" VALUES('Ontertek'); INSERT INTO "tab" VALUES('ZTPay'); Pntertek & Ontertek are fuzzy duplicates of the correctly spelt Intertek. I wish to create a list consisting of fuzzy duplicates and the correctly spelt names. However, I don't want the list to contain the correctly spelt name if there is no fuzzy duplicate found by the LIKE search.

How to control SQLite in memory DB consumption using C# vb.net

你。 提交于 2020-01-23 18:58:06
问题 I have 100 GB data. I want to load it in-memory using SQLite in VB.Net. I have 32 GB RAM. I want SQLite to take 24 GB RAM and other 8 GB will remain free for other OS tasks. When it hits the 24 GB RAM limit It should start flushing data to some disk file automatically. First: I used in-memory DB. Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=:memory:") But it consumes 31.8 GB RAM, and then OS (Windows 7) jump in and takes the control and start using virtual memory (which

What is the best way to read binary image from blob SQLite and decode it using OpenCV imdecode?

微笑、不失礼 提交于 2020-01-23 18:28:29
问题 I'm storing and reading image files from SQLite database in C++, the storing is working fine, but I have failed reading and converting the bytes to OpenCV cv::Mat using imdecode. Here is my code: std::vector<cv::Mat> images; std::vector<string> names; std::vector<int> ids; sqlite3 *db; if (sqlite3_open("fr.db", &db) != SQLITE_OK) { printf("Open database failed\n"); return 0; } sqlite3_stmt *statement; const char* sql = "SELECT * FROM Friends"; if (sqlite3_prepare_v2(db, sql, strlen(sql),

What is the best way to read binary image from blob SQLite and decode it using OpenCV imdecode?

会有一股神秘感。 提交于 2020-01-23 18:28:11
问题 I'm storing and reading image files from SQLite database in C++, the storing is working fine, but I have failed reading and converting the bytes to OpenCV cv::Mat using imdecode. Here is my code: std::vector<cv::Mat> images; std::vector<string> names; std::vector<int> ids; sqlite3 *db; if (sqlite3_open("fr.db", &db) != SQLITE_OK) { printf("Open database failed\n"); return 0; } sqlite3_stmt *statement; const char* sql = "SELECT * FROM Friends"; if (sqlite3_prepare_v2(db, sql, strlen(sql),

How flask-whooshalchemy index data imported manually?

﹥>﹥吖頭↗ 提交于 2020-01-23 18:21:49
问题 I'm using flask-whooshalchemy on sqlite, and mannually imported a lot of data, now whoosh can search none of it. I think it's because whoosh haven't indexed any of the data, right? How could I add whoosh index on those data manually? 回答1: Have a look at https://gist.github.com/davb5/21fbffd7a7990f5e066c I've just written this to solve the same issue - rebuild search indices after a bulk data import. It won't work out of the box for anyone else (my "lib" import contains all of my third party

android sqlite and regular expressions

怎甘沉沦 提交于 2020-01-23 17:48:06
问题 I need to select the query from the database all the names that begin with the letter or letters, but without the letter "x". For some titles that now exists in the following code(It's slow but it works): String qstr = "SELECT SUM("+SQLhelper.COL_COUNT +") FROM " + SQLhelper.TABLE_MYDETAILS + " WHERE " + SQLhelper.COL_DETAILID + " LIKE 'sh%'" + " or " + SQLhelper.COL_DETAILID + " LIKE 'sw%'" + " or " + SQLhelper.COL_DETAILID + " LIKE 'cty%'"+ " or " + SQLhelper.COL_DETAILID + " LIKE 'twn%'"+