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
121
votes
3 answers

SQLite - replace part of a string

Is it possible using SQL in an SQLite table to replace part of a string? For example, I have a table where one of the fields holds the path to a file. Is it possible to replace parts of the string so that,…
colin
  • 2,983
  • 6
  • 41
  • 49
119
votes
16 answers

ALTER TABLE ADD COLUMN IF NOT EXISTS in SQLite

We've recently had the need to add columns to a few of our existing SQLite database tables. This can be done with ALTER TABLE ADD COLUMN. Of course, if the table has already been altered, we want to leave it alone. Unfortunately, SQLite doesn't…
dan04
  • 87,747
  • 23
  • 163
  • 198
119
votes
11 answers

How to import load a .sql or .csv file into SQLite?

I need to dump a .sql or .csv file into SQLite (I'm using SQLite3 API). I've only found documentation for importing/loading tables, not entire databases. Right now, when I type: sqlite3prompt> .import FILENAME TABLE I get a syntax error, since…
happythenewsad
  • 1,765
  • 3
  • 15
  • 17
118
votes
2 answers

How to get first/top row of the table in Sqlite via Sql Query

I need to fetch the first/top row of a table in a Sqlite database. But my program throws an SQLException "Sqlite Syntax Error: Syntax error near '1' " for the query that I am using: SELECT TOP 1 * FROM SAMPLE_TABLE That I guess is a syntax…
Omayr
  • 1,949
  • 4
  • 22
  • 35
118
votes
14 answers

Light weight alternative to Hibernate?

I have a single user java program that I would like to have store data in a light weight database such as Derby or Sqlite. I would like to use a data abstraction layer in my program. Hibernate appears to require a lot of configuration and is…
Jared
  • 39,513
  • 29
  • 110
  • 145
117
votes
10 answers

Where does Android emulator store SQLite database?

I'm working on an Android application that stores data in a SQLite database. My question is, where does this database file get stored on the filesystem when you're using an emulator? I have seen that it's stored in…
I82Much
  • 26,901
  • 13
  • 88
  • 119
116
votes
11 answers

How to find database file version?

I have a few SQLite database files. I want to know the database file version (if the database was created with sqlite2 or sqlite3 or any other main/sub version) not the SQLite library or driver or user_version or schema_version.
Srikanth S
  • 1,717
  • 5
  • 16
  • 21
116
votes
32 answers

Laravel: PDOException: could not find driver

I am developing a website on a server I only have access to MySQL and FTP, so all commands I run are through the b374k php shell . I am experiencing a Laravel problem with SQL driver. I tried switching to file-hosted SQLite (in…
artus90
  • 1,340
  • 2
  • 8
  • 8
116
votes
12 answers

Accessing an SQLite Database in Swift

I'm looking for a way to access an SQLite database in my app with Swift code. I know that I can use an SQLite Wrapper in Objective C and use the bridging header, but I'd rather be able to do this project entirely in Swift. Is there a way to do this,…
Jase
  • 1,369
  • 2
  • 12
  • 24
115
votes
2 answers

Change SQLite default settings

we know when type .mode column let me see tables like column And .headers on , we can see the header of tables. But I want to know if there is any way make the two default settings? Do some modify for the source code of sqlite?? OR is there a…
aelam
  • 2,796
  • 2
  • 27
  • 32
113
votes
2 answers

What is the difference between libsqlite3.dylib and libsqlite3.0.dylib?

I'm getting started with SQLite databases in an app I'm working on. I've not run into issues yet but one of the early steps from this tutorial is linking the SQLite3 framework. The tutorial calls for libsqlite3.0.dylib but I noticed another one…
earnshavian
  • 1,864
  • 2
  • 13
  • 17
113
votes
5 answers

SQLite INSERT - ON DUPLICATE KEY UPDATE (UPSERT)

MySQL has something like this: INSERT INTO visits (ip, hits) VALUES ('127.0.0.1', 1) ON DUPLICATE KEY UPDATE hits = hits + 1; As far as I know this feature doesn't exist in SQLite, what I want to know is if there is any way to achive the same…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
111
votes
9 answers

Opening database file from within SQLite command-line shell

I'm using the SQLite Command Line Shell. As documented, I can open a database by supplying it as an argument to the executable: sqlite3 data.db I cannot figure out how to open a database file from within the tool after having invoked it without…
Nolan Amy
  • 10,785
  • 5
  • 34
  • 45
111
votes
18 answers

Deleting Row in SQLite in Android

This might be a dumb question, but I'm new to SQLite and I can't seem to figure this out. I have 1 table that has columns KEY_ROWID, KEY_NAME, KAY_LATITUDE, and KEY_LONGITUDE. I want the user to be able to select one and delete it; Can anyone give…
user766650
111
votes
10 answers

How to use sqlite3 module with electron?

I want to develop desktop app using electron that uses sqlite3 package installed via npm with the command npm install --save sqlite3 but it gives the following error in electron browser console Uncaught Error: Cannot find module…
manas
  • 6,119
  • 10
  • 45
  • 56