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
205
votes
12 answers

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
  • 12,435
  • 15
  • 71
  • 107
199
votes
5 answers

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) also seems odd. This snippet of code is the…
Shaun Mitchell
  • 2,306
  • 2
  • 15
  • 10
198
votes
5 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
  • 36,270
  • 31
  • 115
  • 154
196
votes
20 answers

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 has been forcefully stopped". Please check my…
Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160
195
votes
4 answers

sqlite alter table add MULTIPLE columns in a single statement

Is it possible to alter table add MULTIPLE columns in a single statement in sqlite? The following would not work. alter table test add column mycolumn1 text, add column mycolumn2 text;
user775187
  • 22,311
  • 8
  • 28
  • 36
189
votes
11 answers

What is a good choice of database for a small .NET application?

I'm developing a small application with C# in .NET and I want to have a small light weight database which does not use much resources. Could you please list some of the best known light weight database softwares.
ePezhman
  • 4,010
  • 7
  • 44
  • 80
188
votes
9 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
  • 74,180
  • 73
  • 171
  • 204
188
votes
14 answers

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 enabled. Most examples assume you're creating the…
Dane O'Connor
  • 75,180
  • 37
  • 119
  • 173
183
votes
5 answers

Pros and Cons of SQLite and Shared Preferences

What is the good mechanism to store information among SQLite database and Shared Preferences? Why use shared preferences? Why use sqlite? I tried to find the difference between them, and which is the better mechanism for data storing, but I am…
Rana.S
  • 2,265
  • 3
  • 20
  • 19
181
votes
7 answers

How to have an automatic timestamp in SQLite?

I have an SQLite database, version 3 and I am using C# to create an application that uses this database. I want to use a timestamp field in a table for concurrency, but I notice that when I insert a new record, this field is not set, and is…
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
177
votes
16 answers

How can I get dict from sqlite query?

db = sqlite.connect("test.sqlite") res = db.execute("select * from table") With iteration I get lists coresponding to the rows. for row in res: print row I can get name of the columns col_name_list = [tuple[0] for tuple in…
Meloun
  • 13,601
  • 17
  • 64
  • 93
176
votes
13 answers

Get boolean from database using Android and SQLite

How can I obtain the value of a boolean field in an SQLite database on Android? I usually use getString(), getInt(), etc. to get the values of my fields, but there does not seem to be a getBoolean() method.
Kevin Bradshaw
  • 6,327
  • 13
  • 55
  • 78
175
votes
7 answers

How to auto create database on first run?

My application being ported to .NET Core will use EF Core with SQLite. I want to automatically create the database and tables when the app is first run. According to documentation this is done using manual commands : dotnet ef migrations add…
deandob
  • 5,100
  • 5
  • 25
  • 37
175
votes
1 answer

Create SQLite Database and table

Within C# application code, I would like to create and then interact with one or more SQLite databases. How do I initialize a new SQLite database file and open it for reading and writing? Following the database's creation, how do I execute a DDL…
TinKerBell
  • 2,111
  • 2
  • 14
  • 12
171
votes
9 answers

SQLite with encryption/password protection

I'm just learning to use SQLite and I was curious if such is possible: Encryption of the database file? Password protect opening of the database? PS. I know that there is this "SQLite Encryption Extension (SEE).", but according to the…
ahmd0
  • 16,633
  • 33
  • 137
  • 233