An extremely simple database written in the Julia Programming Language. This is a very rudimentary database and lacks many features you would expect in a production-ready system, such as indexing for fast lookups, transactions, concurrency control, error handling, data integrity checks, and more. It is intended to be used for small projects where you need a database but don't want to deal with the overhead of setting up a full-fledged database.
I've been learning Julia and this seemed like a fun project to create.
Julia was designed from the beginning for high performance. Julia programs compile to efficient native code for multiple platforms via LLVM.
Julia is dynamically typed, feels like a scripting language, and has good support for interactive use.
Reproducible environments make it possible to recreate the same Julia environment every time, across platforms, with pre-built binaries.
Julia uses multiple dispatch as a paradigm, making it easy to express many object-oriented and functional programming patterns. The talk on the Unreasonable Effectiveness of Multiple Dispatch explains why it works so well.
Julia provides asynchronous I/O, metaprogramming, debugging, logging, profiling, a package manager, and more. One can build entire Applications and Microservices in Julia.
Julia is an open source project with over 1,000 contributors. It is made available under the MIT license. The source code is available on GitHub.
brew install --cask julia
or
Download and install from julialang.org
Since this is a simple project, there is no installation process per se. You just need to clone the repository and ensure you have Julia installed on your system.
git clone https://github.com/erictherobot/tinydb-julia.git
This project provides a TinyDB struct that represents the database and and functions to interact with the database.
storeretrieveHere is a basic example:
include("src/TinyDB.jl")
# create a new database
db = TinyDB("mydb.txt")
# store a key-value pair in the database
store(db, "Hello", "World")
# retrieve the value for a given key
println(retrieve(db, "Hello")) # prints "World"
The database is stored in a text file. The file format is very simple: each line contains a key-value pair separated by a colon. For example, the following file contains two key-value pairs:
To run the example, use the following command:
julia example.jl
This will create a database file called mydb.txt and store the key-value pair "Hello": "World" in the database. It will then retrieve the value for the key "Hello" and print it to the console.
This project includes a small set of tests. You can run the tests with the following command:
julia test/runtests.jl
which should produce the following output:
Test Summary: | Pass Total Time
TinyDB Tests | 3 3 0.1s
These tests verify basic functionality such as storing and retrieving key-value pairs, and overwriting existing keys with new values. They also test that the database file is created if it does not already exist.
While this project is intentionally simple, there are many ways it will be extended:
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this useful as is please let me know. If you find any bugs, please feel free to submit a pull request or open an issue. If you have any questions, you can contact me.
Please consider Buying Me A Coffee. I work hard to bring you my best content and any support would be greatly appreciated. Thank you for your support!