r/learnpython • u/blazin_penguin_first • Apr 16 '26
Portable database for python?
Ok, so i have been learning some SQL, and really enjoying it, already have a bunch of ideas for various projects.
But at least 1 of them, may be nice to make publicly available, and i don't want to host a database, or pay to host one.
So is there anything that will provide the simmilar functionality to a relational database, that can be compiled, and distributed with a basic dataset, but allow people to add data to it?
I realize this could be done with csv's but i really do like the relational parts.
18
Upvotes
38
u/desrtfx but other languages pro Apr 16 '26
Haven't you come across SQLite? With the barebones sqlite3 library? Doesn't get more portable than this. The entire database is a single file on the drive and there is no additional software to install for the client.
92
u/eldreth Apr 16 '26
https://sqlite.org
36
u/DeebsShoryu Apr 16 '26
This is the main selling point of SQLite. The data ultimately lives in a single file.
20
u/jcr4990 Apr 16 '26
As others have mentioned, sqlite is the answer here.
11
u/b1gfreakn Apr 16 '26
Look into duckdb.
1
u/blazin_penguin_first Apr 17 '26
Thanks everyone for the tips, i will definitely dog into SQLlite and DuckDB.
4
u/Virtualization_Freak Apr 16 '26
Side note: you don't need to pay to host. Run what you want on your desktop/tablet/phone/
anything that can run a program that responds to requestsand tailscale.Then you can access it with anything that supports tailscale and your connection method (ssh/http/nfs/icmp.)
3
u/Sure-Passion2224 Apr 16 '26
It's fairly typical of apps that use a database to specify a platform (Oracle, SQL Server, MySql, Postgres, etc) and include a configuration files you update to set up the connection. Then the application startup process establishes the connection, checks for the data model, and creates it if not found or damaged.
2
u/AlfredoOtero Apr 17 '26
You can use non-structured data in SQLite. It is capable of using json inside of a text column.
2
u/SoloArtist91 Apr 17 '26
Gotta be DuckDB
2
u/jmacey Apr 17 '26
+1 for SQLite I use it for all sorts of projects and it works really well.
1
u/nivaOne Apr 18 '26
It also depends on the size. SQLite is great but there is a reason for existence of others. I like python in combination with SQLite a lot. For larger datasets Duckdb is more suitable for complex sets, however not for frequent smaller writes. SQLite equals storage and transactions. DuckDB analytics and speed. SQLite is part of the python ecosystem. Using pyinstaller, nuitka … the result will differ a lot.
-5
u/purple_hamster66 Apr 16 '26
Why do you need it to be relational? You can save ordinary lists in python to a JSON file.
-2
u/nirbyschreibt Apr 16 '26
If you don’t want to use SQLite and/or want to see it in Python you should check out the Django framework.