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 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 makes a tailored toy database with appropriate structure and sample data). Also consider making a db fiddle and sharing the link (there are multiple free such services out there; see, for example, this and this).

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.

When seeking assistance with an SQL query, structure your query accordingly (see tips for asking a good SQL question).

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

94030 questions
257
votes
49 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
  • 3,019
  • 2
  • 16
  • 19
255
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,535
  • 3
  • 22
  • 16
251
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
  • 34,961
  • 21
  • 83
  • 129
244
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,398
  • 5
  • 21
  • 35
243
votes
8 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,439
  • 2
  • 15
  • 3
240
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,361
  • 9
  • 31
  • 29
238
votes
7 answers

Creating stored procedure in SQLite

Is it somehow possible to create a stored procedure when using SQLite?
grady
  • 12,281
  • 28
  • 71
  • 110
237
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
  • 2,373
  • 2
  • 14
  • 4
237
votes
4 answers

"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( (SELECT _id FROM Users WHERE…
user2780638
  • 2,503
  • 2
  • 13
  • 8
235
votes
7 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,622
  • 34
  • 63
  • 66
232
votes
7 answers

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
  • 19,880
  • 21
  • 76
  • 94
232
votes
8 answers

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') ); This gives an error.
Joep
  • 4,003
  • 3
  • 28
  • 32
226
votes
27 answers

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, in import_module __import__(name) File…
Alexander van Dijk
  • 2,361
  • 2
  • 14
  • 3
217
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
  • 108,121
  • 75
  • 161
  • 195
215
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…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622