Professional Documents
Culture Documents
SQLite The Only Database You Will Ever Need in Most Cases
SQLite The Only Database You Will Ever Need in Most Cases
unixsheikh.com
The name SQLite is a nice name, but the "lite" part is misleading,
it sounds like it is only useful for tiny things - which is very
wrong. SQLite should be named AwesomeSQL, because that is what it
is. SQLite is probably the only database you will ever need in most
cases.
Even if you start out small and later need to upscale, as long as your
web application can run on the same machine as the database, which it
can in 99% of the time, you can just upgrade the hardware to a beefier
machine and keep business as usual.
https://www.unixsheikh.com/articles/sqlite-the-only-database-you-will-ever-need-in-most-cases.html 1/4
17/02/2023, 19:31 SQLite the only database you will ever need in most cases
Most problems arise when you follow trends and hype and put your
applications together by all the "shiny stuff". Then you have all the
added complexity because of all the abstractions, and all these things
cause problems once performance becomes an important factor.
If you setup SQLite correctly, then in about 99% of the time you
actually only need that.
You can split up your database into multiple separate databases, and
you can even give each user his/hers own database on the server.
Depending on the application type, you can have a single database that
contains all user account information, such as username and password,
and you use this for the login session, but once the login has been
confirmed, you use another personal database for the work the client
is doing. Should the client ever need a copy of his database, simply
copy the file and ship it.
https://www.unixsheikh.com/articles/sqlite-the-only-database-you-will-ever-need-in-most-cases.html 2/4
17/02/2023, 19:31 SQLite the only database you will ever need in most cases
Take a look at the Command Line Shell For SQLite to see some of the
really cool stuff you can do with SQLite.
Dynamic and weakly types SQL syntax means that you can insert a string
into a column defined as an integer. SQLite will attempt to convert
data between formats where appropriate, the string "123" into an
integer in this case, but it does not guarantee such conversions and
will store the data as-is if such a conversion is not possible. This
is not a bug, but it is considered a feature (see under "Manifest
typing").
Useful settings
You can list all supported PRAGMA keys for setup with:
PRAGMA pragma_list;
The settings below are some of the settings I use when I deploy SQLite
on a web application. Many other relevant settings exist and your
millage may vary.
WALand busy_timeout are the most important setting when working with a
web application.
If e.g. you're using the native SQLite driver in PHP, you need to set
the following for each connection:
$sqlite_db->busyTimeout(30000);
https://www.unixsheikh.com/articles/sqlite-the-only-database-you-will-ever-need-in-most-cases.html 3/4
17/02/2023, 19:31 SQLite the only database you will ever need in most cases
If you're using PHP PDO instead, then you need to set it like this:
array(
...
);
Final notes
SQLite is one of those projects that I wish I had known about long
before I did. I had heard about it, but for many years I never thought
about taking a serious look at it because I was under the false
impression that is was a tiny database only useful for personal
address books and small embedded devices.
Relevant reading
Consider SQLIte
Consider SQLIte (Hacker News)
Consider SQLIte (Lobsters)
Distinctive Features Of SQLite
SQLite Autoincrement
SQLite FAQ
Why SQLite succeeded as a database (Hacker News)
SQLite small blob storage: 35% Faster Than the Filesystem (Hacker
News)
SQLite: Small, Fast, Reliable – Choose any three (Hacker News)
If you have any comments or corrections please feel free to email them
to me. Also, if you found any of the content on this website useful
consider supporting me on Patreon ;)
https://www.unixsheikh.com/articles/sqlite-the-only-database-you-will-ever-need-in-most-cases.html 4/4