SQLite is the lightweight database engine used for everything from Android applications through to high performance web servers. Recently highly available, distributed, high-throughput versions of SQLite have started cropping up too.
Beekeeper Studio Is A Free & Open Source Database GUIBest SQL query & editor tool I have ever used. It provides everything I need to manage my database. - ⭐⭐⭐⭐⭐ Mit
Beekeeper Studio is fast, intuitive, and easy to use. Beekeeper supports loads of databases, and works great on Windows, Mac and Linux.
Beekeeper's Linux version is 100% full-featured, no cut corners, no feature compromises.A big reason for all the developer attention is the simplicity of how SQLite works. SQLite doesn’t require a software installation, in fact you don’t need to install anything at the system-level. One can simply install the sqlite3
driver for your programming language of choice, and start using SQLite without any other work. All the database logic is handled in the driver code.
In the SQLite model, each database is a file, usually a file that ends in .db
, or .sqlite3
, for example a file named finances.db
.
This is different to traditional database engines like PostgreSQL, or MySQL where a database
is just another ‘entity’ to interact with, just like a table, function, or view.
In traditional database engines, you create a database in much the same way you create any other type of entity.
For example in PostgreSQL you execute CREATE DATABASE finances
, in much the same way you execute CREATE TABLE employees
, or CREATE FUNCTION calculate_salaries
.
So if you can’t create a database from the SQLite prompt, how can you create a database?
Well remember that SQLite databases are files? Well a new database is simply an empty file that ends in .db
. We don’t need a SQLite client to create one of those, although we can use the sqlite3 client, as you’ll see below.
On Linux, MacOS, or WSL, open the terminal and touch a new database file to create it:
This creates a 0-byte database file which is totally valid for SQLite! Try opening it (see below).
Creating a SQLite database on WindowsThere are a couple of ways to do this on Windows - using the file explorer, or using the command prompt.
Creating a database using ExplorerOpen the folder you want to create a database in, right click, select New
-> Text File
.
Then rename the file to finances.db
, make sure to replace the .txt
extension with .db
(you will need to enable view file extensions first).
Open the command prompt or PowerShell and run:
This creates an empty database file in much the same way as touch
does on Mac and Linux.
If you have the sqlite3 cli tool, you can run:
This creates the database and immediately connects to it.
Creating a SQLite database using Python, NodeJS, or other languageYou can also create a database directly from your programming language of choice. Much like the SQLite3 cli you don’t need to actually create the .db
file before connecting to it, the driver will create the database and connect to it all in one go.
import sqlite3
con = sqlite3.connect('finances.db')
con.close() # connection closed, database created.
NodeJS
const sqlite3 = require('sqlite3')
const db = new sqlite3.Database('finances.db');
db.close() // connection closed, database created.
Opening your newly created SQLite database file
If you have Beekeeper Studio installed, you can just double click the finances.db
file in your file browser.
Beekeeper’s default file-associations also work in the terminal (I usually have a terminal open, so sometimes this is easier).
open finances.db
xdg-open finances.db
start finances.db
All three of these will open the .db
file in Beekeeper Studio if you have it configured as your default SQLite database handler (this is the default).
I’m a huge fan of SQLite, in fact Beekeeper Studio stores all of it’s configuration data in a SQLite database in your home directory.
Hopefully now you know how to create a new database, you can use it even more. :-).
Beekeeper Studio - DB Browser for SQLiteBeekeeper Studio is an easy to use DB browser for SQLite. Simply open the file and edit your database contents in the same way you would edit a spreadsheet.
Download Beekeeper Studio here
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4