Linked Questions
26 questions linked to/from SQLite INSERT - ON DUPLICATE KEY UPDATE (UPSERT)
2 votes
2 answers
1k views
SQLite UPSERT with 2 constraints [duplicate]
I have an sql table with 3 columns, none of which is UNIQUE ( but the pair name + role is ): Name | Role | Votes What I need to do is, write an sqllite query that stick to the following rules : If a ...
2 votes
0 answers
3k views
sqlite3.OperationalError: near "ON": syntax error [duplicate]
What is wrong with this SQL line? I've verified the types are correct. c.execute('''INSERT into stock_table (item_name, stock, price) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE stock=VALUES(stock);'''...
0 votes
1 answer
2k views
android.database.sqlite.SQLiteException: near "ON": syntax error (code 1): , while compiling: INSERT INTO [duplicate]
It would be helpful if someone could tell me correct syntax for updating tables in sqlite. I want to update table using sqlite but I am getting the following error: android.database.sqlite....
0 votes
2 answers
1k views
PDO "ON DUPLICATE KEY UPDATE" prepared statement [duplicate]
I am attempting a prepared statement for the first time based on this thread. So far I am getting the error message SQLSTATE[HY000]: General error: 1 near "ON": syntax error Here is the query followed ...
-1 votes
1 answer
106 views
How to insert variable to sql table in python if variable is not already in table? [duplicate]
Im having a problem with my sqlite database in my python program. I'm trying to create a table that will hold records of players score. Player name is saved as variable "val" and that ...
0 votes
0 answers
76 views
Update data in SQlite database [duplicate]
There is a parser script in curl, as well as a script that creates a database and writes sparse data to this database. How to make sure that each time the script is run, the sparse data is not written ...
629 votes
19 answers
403k views
UPSERT *not* INSERT or REPLACE
http://en.wikipedia.org/wiki/Upsert Insert Update stored proc on SQL Server Is there some clever way to do this in SQLite that I have not thought of? Basically I want to update three out of four ...
102 votes
7 answers
144k views
How to copy data from one table to another (where both have other fields too that are not in common)?
I have 2 tables Source and Destination that have the same fields. ID and COUNTRY, though they both have other fields too that are not in common. I need to copy the Source.Country value to the ...
5 votes
2 answers
12k views
On Duplicate Key not working in SQLite
In my table, id is the primary key, but this code not working in sqlite3: insert into text (id,text) VALUES(150574,'Hello') ON DUPLICATE KEY UPDATE 'text' = 'good' Please help me.
5 votes
1 answer
15k views
How to use REPLACE Command in SQLite if there is two or more conditons
I want to update a row if it exists in the table else insert it in SQLite in single query. From SQLite documentation I found out that we can use REPLACE command for achieving this. I want to know how ...
5 votes
2 answers
3k views
Insert or Replace with sum of old values
I am building Inventory Application using PhoneGap.In that i have one module STOCK for stock management. Stock Table Query CREATE TABLE STOCK ( sto_id INTEGER PRIMARY KEY AUTOINCREMENT, ...
4 votes
2 answers
5k views
Python - Bulk Select then Insert from one DB to another
I'm looking for some help on how to do this in Python using sqlite3 Basically I have a process which downloads a DB (temp) and then needs to insert it's records into a 2nd identical DB (the main db).....
5 votes
2 answers
4k views
Web scraping with python and sqlite. How to store scraped data effectively?
I want to scrape some specific webpages on a regular basis (e.g. each hour). This I want to do with python. The scraped results should get inserted into an SQLite table. New info will be scraped but ...
3 votes
3 answers
8k views
Insert row into table if it is empty and replace the existing row if it isn't in SQLite
I have a table in SQLite 3: CREATE TABLE foo ( bar TEXT ); It always has 0 or 1 rows. I want to write a query which updates the row if there is 1 row and adds the row if there are 0. What is the ...
-1 votes
2 answers
5k views
java.sql.SQLException: near "ON": syntax error
Hey guys I have scoured the many other answers and am still unable to figure out this problem. statement.executeUpdate("CREATE TABLE IF NOT EXISTS recentlyWatched (fileName STRING NOT NULL, ...