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
350
votes
9 answers

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 follows: CREATE TABLE Book ID INTEGER PRIMARY KEY…
SparkyNZ
  • 6,266
  • 7
  • 39
  • 80
340
votes
2 answers

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
  • 3,811
  • 3
  • 20
  • 25
336
votes
5 answers

How to use an existing database with an Android application

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 the application gain access to this database and…
Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193
336
votes
9 answers

Java and SQLite

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-werner.de/javasqlite, but are there other more…
Scott Bennett-McLeish
  • 9,187
  • 11
  • 41
  • 47
331
votes
23 answers

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: SQLite error near "DROP": syntax error
Sandip
  • 3,501
  • 3
  • 19
  • 23
328
votes
16 answers

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 SQLite was not mentioned. From the SQLite…
joce
  • 9,624
  • 19
  • 56
  • 74
326
votes
38 answers

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
  • 8,217
  • 6
  • 45
  • 57
319
votes
15 answers

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 of tens of similar questions every week. Attempting to…
laalto
  • 150,114
  • 66
  • 286
  • 303
316
votes
4 answers

Core Data vs SQLite 3

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 it for use in my next application. Is there much…
Jason Medeiros
  • 5,358
  • 3
  • 25
  • 18
300
votes
5 answers

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 data, drop the table, recreate table and…
Eno
  • 10,730
  • 18
  • 53
  • 86
298
votes
8 answers

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

How can I see the structure of table in SQLite as desc was in Oracle?
Ali
  • 10,774
  • 10
  • 56
  • 83
291
votes
15 answers

Any good ORM tools for Android development?

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 that given the object definition, can…
GWLlosa
  • 23,995
  • 17
  • 79
  • 116
289
votes
3 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
  • 3,275
  • 3
  • 16
  • 15
271
votes
12 answers

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

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?
ian93
  • 1,488
  • 4
  • 24
  • 37
263
votes
19 answers

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. /usr/bin/ruby1.8 extconf.rb checking for…
Dmitry
  • 7,300
  • 6
  • 32
  • 55