sqlite

Merging two SQLite databases (C#)

只谈情不闲聊 提交于 2020-01-25 08:50:07
问题 How would I go about merging two SQLite database files in C#? I found and read this question: Merging two SQLite database files (C# .NET) but I could not get it working. I feel it might be a bit outdated, are there any more "modern" solutions? 来源: https://stackoverflow.com/questions/59115084/merging-two-sqlite-databases-c

Merging sqlite databases through a bash script

谁说我不能喝 提交于 2020-01-25 08:45:08
问题 Thanks to previous SO posts I can now merge sqlite databases. But I want to run this merging in an automatic way using a bash script, I have tried various ways and here is my latest and most complete fail: ## DB to merge I1=d1.db I2=d2.db ## Command to run CMD='attach \'d2.db\' as toMerge; BEGIN; insert into sae select * from toMerge.sae; COMMIT; detach toMerge;' echo $CMD ## Pass to sqlite sqlite3 $I1 $CMD Two issues meet here: 1- passing a bash variable (here d2.db). I had tried with the

Room - Database gets locked after a delete query

一笑奈何 提交于 2020-01-25 08:34:07
问题 I'm trying to delete a row from my database. When I first delete it for the first time, the row gets removed successfully. After I try to remove another row, I get an error that the db is not open/ is locked. I have posted the logcat and the code. Also, if I delete a row for the first time, it gets delete and when I close the app and open it back again and delete another row, it works. Only if I continue to delete another row without closing the app, I get the error. Here's the log: Caused by

Copy SEVERAL Column Values from One table into Another Matching IDs - SQLite

若如初见. 提交于 2020-01-25 08:04:07
问题 I'm elaborating on this question (Copy Column Value from One table into Another Matching IDs - SQLite) by adding an extra challenge. The idea is to copy the value of several columns from one table to another when an id is matching. The aforementioned question addresses how to copy the content of one column when a matching id is found. Here the code as posted by @scaisEdge: UPDATE t1 SET value = ( SELECT value FROM t2 WHERE t1.ID = t2.ID) But what if we want to update several columns from that

Copy SEVERAL Column Values from One table into Another Matching IDs - SQLite

怎甘沉沦 提交于 2020-01-25 08:04:03
问题 I'm elaborating on this question (Copy Column Value from One table into Another Matching IDs - SQLite) by adding an extra challenge. The idea is to copy the value of several columns from one table to another when an id is matching. The aforementioned question addresses how to copy the content of one column when a matching id is found. Here the code as posted by @scaisEdge: UPDATE t1 SET value = ( SELECT value FROM t2 WHERE t1.ID = t2.ID) But what if we want to update several columns from that

Android - sqlite in clause using string values from array?

穿精又带淫゛_ 提交于 2020-01-25 07:49:07
问题 I want to execute a sqlite query, I have a String : String A = "AB-CDFER-GTDOL"; String[] parts = Pattern.compile("-", Pattern.LITERAL).split(A); Now I need to use from parts in my query . cursor = sql.rawQuery("SELECT * FROM MyTable WHERE Comment in" + ?????, null); How I can use from parts in my query . For example I need to have ("AB","CDFER","GTDOL") 回答1: You can compile a string after split: String A = "AB-CDFER-GTDOL"; String[] parts = Pattern.compile("-", Pattern.LITERAL).split(A); //

sqlite3 insert into dynamic table

戏子无情 提交于 2020-01-25 07:19:07
问题 I am using sqlite3 (maybe sqlite4 in the future) and I need something like dynamic tables. I have many tables with the same format: values_2012_12_27, values_2012_12_28, ... (number of tables is dynamic) and I want to select dynamically the table that receives some data. I am using _sqlite3_prepare with INSERT INTO ? VALUES(?,?,?) . Ofcourse this fails to compile (syntax error near ?). There is a nice and simple way to do this in sqlite ? Thanks 回答1: Using SQL parameters is not possible for

Peewee ORM sqlite create db with list of nested dictionaries from Google Analytics

和自甴很熟 提交于 2020-01-25 07:08:31
问题 I have a simple problem. I am new to object oriented programming.. I have one big list of nested dictionaries, that should be presented within several tables. What I don't understand is how I can use objects to make this simpler. I am getting Google Analytics data for each user. LOGIC OF MY CODE: get the data for a single user (This data is in the format like this: {'sampleRate': 1, # Pageview activity 'sessions': [{'activityTime': '2020-01-08T15:48:38.012671Z', 'activityType': 'PAGEVIEW',

How to create a new table in Room dynamically?

天涯浪子 提交于 2020-01-25 05:43:09
问题 Help me out please. In my app user is able to create new database tables by pressing a button. User is also able to access this tables later to receive data from them. Currently I utilize good old SQLite via dataBaseHelper class, so I could just public static void createTable(String tableName) { databaseHelper.getWritableDatabase().execSQL("CREATE TABLE IF NOT EXISTS [" + tableName + "] (...columns)"); } and the job was done; Now I want to use Room library in my App instead of DataBaseHelper.

Apostrophe in SQLite select query

99封情书 提交于 2020-01-25 05:42:04
问题 I have a problem with SQLite and a bit of bespoke SQL: public Cursor getExistingSpeciesDetails(String sub_id, String english_name) { Cursor c = mDb.rawQuery( "SELECT mobileobs.how_many, mobileobs.comment, mobileobs.sensitive, " + "mobileobs.breeding_evidence from mobileobs " + "WHERE mobileobs.sub_id = '" + sub_id + "' and mobileobs.english_name = '" + english_name + "'", null); return c; } My problem is an apostrophe in the english name (Cetti's Warbler) is causing an error in the SQL (force