Questions tagged [sqlite]

SQLite is an open-source software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world.

sqlite
Filter by
Sorted by
Tagged with
3376 votes
12 answers
497k views

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop ...
1376 votes
19 answers
1.2m views

How can I list the tables in a SQLite database file that was opened with ATTACH?

What SQL can be used to list the tables, and the rows within those tables in an SQLite database file – once I have attached it with the ATTACH command on the sqlite3 command line tool?
izb's user avatar
  • 50.9k
1111 votes
32 answers
604k views

How do I check in SQLite whether a table exists?

How do I, reliably, check in SQLite, whether a particular user table exists? I am not asking for unreliable ways like checking if a "select *" on the table returned an error or not (is this even a ...
PoorLuzer's user avatar
  • 24.7k
751 votes
9 answers
369k views

SQLite primary key on multiple columns

What is the syntax for specifying a primary key on more than 1 column in SQLite ?
Bogdan Gavril MSFT's user avatar
726 votes
10 answers
239k views

How can I avoid concurrency problems when using SQLite on Android?

What would be considered the best practices when executing queries on an SQLite database within an Android app? Is it safe to run inserts, deletes and select queries from an AsyncTask's ...
Vidar Vestnes's user avatar
664 votes
26 answers
512k views

How to insert multiple rows in SQLite?

In MySQL you can insert multiple rows like this: INSERT INTO 'tablename' ('column1', 'column2') VALUES ('data1', 'data2'), ('data1', 'data2'), ('data1', 'data2'), ('data1', 'data2'); ...
Andrew's user avatar
  • 233k
625 votes
19 answers
386k 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 ...
Mike Trader's user avatar
  • 8,634
599 votes
25 answers
801k views

How to get a list of column names on Sqlite3 database?

I want to migrate my iPhone app to a new database version. Since I don't have some version saved, I need to check if certain column names exist. This Stackoverflow entry suggests doing the select ...
luebken's user avatar
  • 6,531
544 votes
17 answers
185k views

What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?

I have a project in which I'd like to use some of the .NET 4.0 features but a core requirement is that I can use the System.Data.SQLite framework which is compiled against 2.X. I see mention of this ...
jamone's user avatar
  • 17.3k
500 votes
9 answers
261k views

Is there an SQLite equivalent to MySQL's DESCRIBE [table]?

I'm just getting started learning SQLite. It would be nice to be able to see the details for a table, like MySQL's DESCRIBE [table]. PRAGMA table_info [table] isn't good enough, as it only has basic ...
Matthew's user avatar
  • 28.6k
418 votes
7 answers
393k views

How do I add a new column in between two columns?

I have a table with columns name, qty, rate. I need to add a new column COLNew in between the name and qty columns. How do I add a new column in between two columns?
Tester's user avatar
  • 4,555
384 votes
8 answers
289k views

How to get Top 5 records in SqLite?

I have tried this which did not work. select top 5 * from [Table_Name]
Amitabh's user avatar
  • 60k
383 votes
8 answers
382k views

Store boolean value in SQLite

What is the type for a BOOL value in SQLite? I want to store in my table TRUE/FALSE values. I could create a column of INTEGER and store in it values 0 or 1, but it won't be the best way to implement ...
Ilya Suzdalnitski's user avatar
369 votes
8 answers
239k views

How to set Sqlite3 to be case insensitive when string comparing?

I want to select records from sqlite3 database by string matching. But if I use '=' in the where clause, I found that sqlite3 is case sensitive. Can anyone tell me how to use string comparing case-...
quantity's user avatar
  • 4,131
369 votes
9 answers
211k views

What are the performance characteristics of sqlite with very large database files? [closed]

2020 update, about 11 years after the question was posted and later closed, preventing newer answers. Almost everything written here is obsolete. Once upon a time sqlite was limited to the memory ...
Snazzer's user avatar
  • 7,774
360 votes
9 answers
562k views

INSERT IF NOT EXISTS ELSE UPDATE?

I've found a few "would be" solutions for the classic "How do I insert a new record or update one if it already exists" but I cannot get any of them to work in SQLite. I have a table defined as ...
SparkyNZ's user avatar
  • 6,476
352 votes
2 answers
279k views

Create table in SQLite only if it doesn't exist already

I want to create a table in a SQLite database only if doesn't exist already. Is there any way to do this? I don't want to drop the table if it exists, only create it if it doesn't.
user461112's user avatar
  • 3,931
344 votes
23 answers
420k views

How to delete or add column in SQLITE?

I want to delete or add column in sqlite database I am using following query to delete column. ALTER TABLE TABLENAME DROP COLUMN COLUMNNAME But it gives error System.Data.SQLite.SQLiteException: ...
Sandip's user avatar
  • 3,631
337 votes
5 answers
226k views

How to use an existing database with an Android application [duplicate]

I have already created an SQLite database. I want to use this database file with my Android project. I want to bundle this database with my application. Instead of creating a new database, how can ...
Muhammad Umar's user avatar
336 votes
9 answers
316k views

Java and SQLite [closed]

I'm attracted to the neatness that a single file database provides. What driver/connector library is out there to connect and use SQLite with Java. I've discovered a wrapper library, http://www.ch-...
Scott Bennett-McLeish's user avatar
334 votes
16 answers
222k views

How do I rename a column in a SQLite database table?

I would need to rename a few columns in some tables in a SQLite database. I know that a similar question has been asked on stackoverflow previously, but it was for SQL in general, and the case of ...
joce's user avatar
  • 9,754
329 votes
38 answers
597k views

How do I unlock a SQLite database?

When I enter this query: sqlite> DELETE FROM mails WHERE (id = 71); SQLite returns this error: SQL error: database is locked How do I unlock the database so this query will work?
ryantm's user avatar
  • 8,257
319 votes
15 answers
138k views

When does SQLiteOpenHelper onCreate() / onUpgrade() run?

I have created my tables in my SQLiteOpenHelper onCreate() but receive SQLiteException: no such table or SQLiteException: no such column errors. Why? NOTE: (This is the amalgamated summary ...
317 votes
4 answers
95k views

Core Data vs SQLite 3 [closed]

I am already quite familiar with relational databases and have used SQLite (and other databases) in the past. However, Core Data has a certain allure, so I am considering spending some time to learn ...
Jason Medeiros's user avatar
312 votes
8 answers
366k views

How can one see the structure of a table in SQLite? [duplicate]

How can I see the structure of table in SQLite as desc was in Oracle?
Ali's user avatar
  • 11.1k
305 votes
5 answers
113k views

Version of SQLite used in Android?

What is the version of SQLite used in Android? Reason: I'm wondering how to handle schema migrations. The newer SQLite versions support an "ALTER TABLE" SQL command which would save me having to copy ...
Eno's user avatar
  • 10.8k
297 votes
3 answers
317k views

sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 74 supplied

def insert(array): connection=sqlite3.connect('images.db') cursor=connection.cursor() cnt=0 while cnt != len(array): img = array[cnt] print(array[cnt]) ...
AB49K's user avatar
  • 3,355
291 votes
15 answers
79k views

Any good ORM tools for Android development? [closed]

Anyone working on the Android ('gPhone') have or know of a place where I can find a good ORM tool for it? The code is written in Java, and the database is SQLite. What I would like to find is a tool ...
GWLlosa's user avatar
  • 24.2k
271 votes
12 answers
120k views

Is there a .NET/C# wrapper for SQLite? [closed]

I'd sort of like to use SQLite from within C#.Net, but I can't seem to find an appropriate library. Is there one? An official one? Are there other ways to use SQLite than with a wrapper?
263 votes
19 answers
92k views

sqlite3-ruby install error on Ubuntu

I have the following error during sqlite3-ruby install: Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. ...
Dmitry's user avatar
  • 7,330
262 votes
49 answers
269k views

Unable to load DLL 'SQLite.Interop.dll'

Periodically I am getting the following exception: Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) I am using 1.0.82.0. version,...
xll's user avatar
  • 3,069
261 votes
17 answers
364k views

Quick easy way to migrate SQLite3 to MySQL? [closed]

Anyone know a quick easy way to migrate a SQLite3 database to MySQL?
Stephen Cox's user avatar
  • 3,595
260 votes
5 answers
142k views

Does it matter what extension is used for SQLite database files?

Are there advantages or disadvantages to the file extension used for SQLite databases? It seems that SQLite itself does not require a naming convention, but there might be other reasons that a ...
Fermin's user avatar
  • 35.6k
256 votes
8 answers
155k views

SQLite Concurrent Access

Does SQLite3 safely handle concurrent access by multiple processes reading/writing from the same DB? Are there any platform exceptions to that?
anand's user avatar
  • 2,569
249 votes
7 answers
169k views

SQLite: How do I save the result of a query as a CSV file?

Is there a way I can export the results of a query into a CSV file?
RayLoveless's user avatar
  • 20.4k
247 votes
7 answers
229k views

Creating stored procedure in SQLite

Is it somehow possible to create a stored procedure when using SQLite?
grady's user avatar
  • 12.5k
246 votes
5 answers
276k views

"Insert if not exists" statement in SQLite

I have an SQLite database. I am trying to insert values (users_id, lessoninfo_id) in table bookmarks, only if both do not exist before in a row. INSERT INTO bookmarks(users_id,lessoninfo_id) VALUES( ...
user2780638's user avatar
  • 2,603
245 votes
2 answers
202k views

How to retrieve inserted id after inserting row in SQLite using Python?

How to retrieve inserted id after inserting row in SQLite using Python? I have table like this: id INT AUTOINCREMENT PRIMARY KEY, username VARCHAR(50), password VARCHAR(50) I insert a new row with ...
Jane's user avatar
  • 2,453
244 votes
9 answers
208k views

Best way to work with dates in Android SQLite [closed]

I'm having some trouble working with dates on my Android application that uses SQLite. I have a couple questions: What type should I use to store dates in SQLite (text, integer, ...)? Given the best ...
Filipe's user avatar
  • 3,398
241 votes
3 answers
277k views

How to concatenate strings with padding in sqlite

I have three columns in an sqlite table: Column1 Column2 Column3 A 1 1 A 1 2 A 12 2 C 13 2 B ...
Akshara's user avatar
  • 3,391
240 votes
8 answers
195k views

Escape single quote character for use in an SQLite query

I wrote the database schema (only one table so far), and the INSERT statements for that table in one file. Then I created the database as follows: $ sqlite3 newdatabase.db SQLite version 3.4.0 Enter &...
jpm's user avatar
  • 16.7k
237 votes
29 answers
431k views

No module named _sqlite3

I am trying to run a Django app on my VPS running Debian 5. When I run a demo app, it comes back with this error: File "/usr/local/lib/python2.5/site-packages/django/utils/importlib.py", line 35, ...
Alexander van Dijk's user avatar
237 votes
8 answers
271k views

How to create timestamp column with default value 'now'?

How to create a table with a timestamp column that defaults to DATETIME('now')? Like this: CREATE TABLE test ( id INTEGER PRIMARY KEY AUTOINCREMENT, t TIMESTAMP DEFAULT DATETIME('now') ); ...
Joep's user avatar
  • 4,053
222 votes
14 answers
264k views

How to dump the data of some SQLite3 tables?

How do I dump the data, and only the data, not the schema, of some SQLite3 tables of a database (not all the tables)? The dump should be in SQL format, as it should be easily re-entered into the ...
217 votes
15 answers
249k views

Mac SQLite editor [closed]

I am aware of CocoaMySQL but I have not seen a Mac GUI for SQLite, is there one? My Google search didn't turn up any Mac related GUI's which is why I'm asking here rather than Google.
Teifion's user avatar
  • 110k
208 votes
12 answers
289k views

List of tables, db schema, dump etc using the Python sqlite3 API

For some reason I can't find a way to get the equivalents of sqlite's interactive shell commands: .tables .dump using the Python sqlite3 API. Is there anything like that?
noamtm's user avatar
  • 12.8k
205 votes
5 answers
108k views

Why do you need to create a cursor when querying a sqlite database?

I'm completely new to Python's sqlite3 module (and SQL in general for that matter), and this just completely stumps me. The abundant lack of descriptions of cursor objects (rather, their necessity) ...
Shaun Mitchell's user avatar
202 votes
5 answers
124k views

SQLite table constraint - unique on multiple columns

I can find syntax "charts" on this on the SQLite website, but no examples and my code is crashing. I have other tables with unique constraints on a single column, but I want to add a constraint to the ...
Rich's user avatar
  • 36.5k
200 votes
20 answers
413k views

How to delete all records from table in sqlite with Android?

My app has two buttons, the first button is for deleting record on user input and the second button is for deleting all records. But when I want to delete data it shows the message "Your application ...
Sandip Armal Patil's user avatar
199 votes
14 answers
196k views

How do I add a foreign key to an existing SQLite table?

I have the following table: CREATE TABLE child( id INTEGER PRIMARY KEY, parent_id INTEGER, description TEXT); How do I add a foreign key constraint on parent_id? Assume foreign keys are ...
Dane O'Connor's user avatar

1
2 3 4 5
1898