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
110
votes
10 answers

How to insert a SQLite record with a datetime set to 'now' in Android application?

Say, we have a table created as: create table notes (_id integer primary key autoincrement, created_date date) To insert a record, I'd use ContentValues initialValues = new ContentValues(); initialValues.put("date_created", ""); long rowId =…
droidguy
  • 1,101
  • 2
  • 8
  • 4
110
votes
8 answers

Password Protect a SQLite DB. Is it possible?

I have to face a new little project. It will have about 7 or 9 tables, the biggest of them will grow by a max rate of 1000 rows a month. I thought about SQLite as my db... But i will need to protect the db in case anybody wants to change data from…
Jhonny D. Cano -Leftware-
  • 17,663
  • 14
  • 81
  • 103
109
votes
6 answers

SQLite equivalent to ISNULL(), NVL(), IFNULL() or COALESCE()

I'd like to avoid having many checks like the following in my code: myObj.someStringField = rdr.IsDBNull(someOrdinal) ? string.Empty : rdr.GetString(someOrdinal); I figured I could just have…
Jason Down
  • 21,731
  • 12
  • 83
  • 117
109
votes
4 answers

Sqlite or MySql? How to decide?

Any good rules of thumb on how to decide which of the two to use? And, if you take over an Sqlite database, and the system is expected to "get much larger", how to decide whether to stick with it or move to MySql?
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
109
votes
5 answers

How do I use prepared statements in SQlite in Android?

How do I use prepared statements in SQlite in Android?
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
109
votes
23 answers

Sqlite File Location Core Data

Typically, the sqlite store file for core data apps is located in Library>Application Support>iPhone Simulator>7.1(or whichever version you are using)>Applications>(Whichever folder contains your app)>Documents folder, but I can't find it in IOS…
enlyte
  • 2,757
  • 3
  • 13
  • 13
108
votes
4 answers

converting int to real in sqlite

Division in sqlite return integer value sqlite> select totalUsers/totalBids from (select (select count(*) from Bids) as totalBids , (select count(*) from Users) as totalUsers) A; 1 Can we typecast the result to get the real value of division…
vaichidrewar
  • 9,251
  • 18
  • 72
  • 86
108
votes
4 answers

Deleting duplicate rows from sqlite database

I have a huge table - 36 million rows - in SQLite3. In this very large table, there are two columns: hash - text d - real Some of the rows are duplicates. That is, both hash and d have the same values. If two hashes are identical, then so are the…
Patches
  • 1,423
  • 2
  • 12
  • 11
108
votes
7 answers

How to open and convert sqlite database to pandas dataframe

I have downloaded some datas as a sqlite database (data.db) and I want to open this database in python and then convert it into pandas dataframe. This is so far I have done import sqlite3 import pandas dat = sqlite3.connect('data.db') #connected…
Eka
  • 14,170
  • 38
  • 128
  • 212
107
votes
3 answers

What are the .db-shm and .db-wal extensions in Sqlite databases?

I am seeing some strange behavior with my application and the state of its database file after running some tests that close the database, delete it, and replace it with a test fixture. When I examine the database file with a tool on my debugging…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
107
votes
20 answers

Location of sqlite database on the device

I've created a sqlite database programmatically with the default way of extending SQLiteOpenHelper and overriding onCreate(). This way the db gets created on the fly when needed. I'd like to check the contents of the db file on my OS X machine with…
Pompair
  • 7,083
  • 11
  • 60
  • 69
106
votes
19 answers

Android - Pulling SQlite database android device

I've looked everywhere and i can't find a real precise answer or a tutorial on how, if it is possible, to do this. is it possible to pull in any way a database of an Android device without having to root it? i just need to extract that data in any…
DeX03
  • 1,609
  • 3
  • 14
  • 15
106
votes
6 answers

What if I don't close the database connection in Python SQLite

I am doing something like this... conn = sqlite3.connect(db_filename) with conn: cur = conn.cursor() cur.execute( ... ) with automatically commits the changes. But the docs say nothing about closing the connection. Actually I can use conn…
treecoder
  • 43,129
  • 22
  • 67
  • 91
106
votes
9 answers

IN clause and placeholders

I'm attempting to do the following SQL query within Android: String names = "'name1', 'name2"; // in the code this is dynamically generated String query = "SELECT * FROM table WHERE name IN (?)"; Cursor cursor = mDb.rawQuery(query,…
Nick
  • 6,375
  • 5
  • 36
  • 53
106
votes
8 answers

How to retrieve the last autoincremented ID from a SQLite table?

I have a table Messages with columns ID (primary key, autoincrement) and Content (text). I have a table Users with columns username (primary key, text) and Hash. A message is sent by one Sender (user) to many recipients (user) and a recipient (user)…
Dabblernl
  • 15,831
  • 18
  • 96
  • 148