Questions tagged [sqlite]

SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

SQLite is a 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. The source code for SQLite is in the public domain.

SQLite is a relational database management system contained in a small (~350 KB) C programming library. In contrast to other database management systems, SQLite is not a separate process that is accessed from the client application, but an integral part of it.

SQLite is ACID-compliant and implements most of the SQL standard, using a dynamically and weakly typed SQL syntax that does not guarantee the domain integrity.

Making an MRE for SQLite questions on StackOverflow

Providing a minimal reproducible example for an SQLite-related question is most usefully and conveniently done by showing a few lines in SQLite syntax (i.e. some create table ... and insert ... which make a tailored toy database with appropriate structure and sample data).

This way, potential answerers can easily recreate the database you used for demonstrating the problem and quickly and efficiently provide solution proposals that are supported by test runs and test output. Showing pictures of database viewers or table representations (even in ASCII art) does not provide the same benefits.

If you already have created a database for demonstration purposes, consider using the .dump command of the SQLite commandline tool. It will automatically give you the lines for exactly recreating the database.

Getting familiar with the commandline tool also is a good way of avoiding all potential errors in whatever programming language is used to handle the database. With the commandline tool, you can inspect and analyse data and structure directly.

Mobile Apps

SQlite is commonly used to store data on Android, iOS, and Windows Phone apps since it has a simple implementation, easy to adapt, and quite fast.

Design

Unlike client-server database management systems, the SQLite engine has no standalone processes with which the application program communicates. Instead, the SQLite library is linked in and thus becomes an integral part of the application program.

The application program uses SQLite's functionality through simple function calls, which reduce latency in database access: function calls within a single process are more efficient than inter-process communication. SQLite stores the entire database as a single cross-platform file on a host machine.

References

Books

88183 questions
238
votes
9 answers

Best way to work with dates in Android SQLite

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 way to store dates how do I store It properly…
Filipe
  • 3,338
  • 5
  • 18
  • 33
233
votes
17 answers

Quick easy way to migrate SQLite3 to MySQL?

Anyone know a quick easy way to migrate a SQLite3 database to MySQL?
Stephen Cox
  • 3,361
  • 3
  • 19
  • 16
225
votes
2 answers

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]) cursor.execute('INSERT INTO images…
AB49K
  • 2,567
  • 3
  • 14
  • 15
224
votes
43 answers

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, installing it with nuget in VS2010, OS Win7…
xll
  • 2,689
  • 2
  • 14
  • 14
222
votes
3 answers

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 11 2 I need to select…
Akshara
  • 3,091
  • 8
  • 29
  • 28
218
votes
5 answers

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 particular extension would be useful or problematic -…
Fermin
  • 32,216
  • 20
  • 81
  • 125
215
votes
15 answers

Mac SQLite editor

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
  • 98,441
  • 75
  • 152
  • 192
204
votes
8 answers

sqlite database default time value 'now'

Is it possible in a sqlite database to craete a table that has a timestamp column that default to DATETIME('now') ? Like this: CREATE TABLE test ( id INTEGER PRIMARY KEY AUTOINCREMENT, t TIMESTAMP DEFAULT DATETIME('now') ); This gives an…
Joep
  • 3,623
  • 3
  • 26
  • 32
203
votes
5 answers

Creating stored procedure and SQLite?

Is it somehow possible to create a stored procedure, when using SQLite?
grady
  • 11,053
  • 26
  • 67
  • 107
200
votes
7 answers

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
  • 2,009
  • 2
  • 13
  • 3
199
votes
2 answers

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 example data username="test" and password="test".…
Jane
  • 1,993
  • 2
  • 12
  • 4
195
votes
6 answers

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 ".help" for instructions sqlite> .read…
jpm
  • 16,162
  • 33
  • 60
  • 66
190
votes
13 answers

How do I 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 database later and should be done from the command…
pupeno
  • 256,034
  • 114
  • 324
  • 541
185
votes
10 answers

How Scalable is SQLite?

I recently read this Question about SQLite vs MySQL and the answer pointed out that SQLite doesn't scale well and the official website sort-of confirms this, however. How scalable is SQLite and what are its upper most limits?
GateKiller
  • 68,419
  • 71
  • 167
  • 203
185
votes
4 answers

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 table on two columns. This is what I have that…
Rich
  • 34,878
  • 31
  • 108
  • 151