SQLite Local Usage Guide

SQLite is a file-based embedded database that does not require a standalone service, commonly used as db.sqlite3 in local development with Rails/Django/Flask.


SQLite stores the database as a single file (e.g., db.sqlite3), eliminating the need to start a daemon like MySQL. The access path is a file path rather than localhost:port (unless accessed through an SQL proxy service).

Typical Local Scenarios

FrameworkFile Location
Railsdb/development.sqlite3
Djangodb.sqlite3 (project root)
Laraveldatabase/database.sqlite
NodeCustom .db path

Connection string examples: sqlite:///./db.sqlite3 or file:./app.db

Command Line

sqlite3 db.sqlite3
.tables
.schema users
SELECT * FROM users LIMIT 5;
.quit

Graphical Management

  • DB Browser for SQLite (cross-platform desktop)
  • TablePlus, DBeaver
  • phpLiteAdmin (Web, see our article on phpliteadmin)

Comparison with MySQL/PostgreSQL

ItemSQLitePostgreSQL
DeploymentSingle fileService :5432
Concurrent WriteWeakStrong
Use CaseLocal development, embedded, mobileProduction Web

Python Example

import sqlite3
conn = sqlite3.connect('app.db')
conn.execute('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)')
conn.commit()
conn.close()

Frequently Asked Questions

database is locked
Occurs when multiple processes write simultaneously; avoid multiple server instances writing to the same file during development.

With phpLiteAdmin
For web management of SQLite files, see the phpliteadmin article, requires Apache+PHP.

Conclusion

SQLite does not use localhost:port, and accesses the database through database files, making it the most convenient storage solution for local prototyping and single-user development.

访客计数:------ Best viewed in Netscape Navigator · 800×600 © LocalHost Run