UselessDB
I have built a completely useless database.
I had a couple flights across the country this week so I decided to test some ideas in Rust. If you’re not yet familiar with Rust, it’s a systems language focusing on performance, safety, and concurrency. I’ve really enjoyed using it so far and every day it feels much more natural. I’ve been thinking about database internals a lot recently, and decided to see what it would be like to implement a typed database in Rust using byte buffers. The simplest case is a DB which holds a single variable… so there you have it.
Welcome to UselessDB. It supports 3 types: float, int, and string. There are no drivers, you simply connect over a raw socket. It’s retro.
telnet localhost 6000
There’s only a handful of commands. The variable is stored in memory, there’s nothing written to disk. You can set the type of the variable as so: type = int
, and set the value var = 5
. Trying to set the value to an incorrect type will fail:
var = 2.0
type_error
You can do comparisons (leading > indicates user input):
> var > 4
true
> var < 10
true
> var >= 5
true
There’s a simple PEG parser written using the Rust-PEG library. I’ll write a post at some point discussing writing PEG parsers for Rust in detail.
Umm.. yeah that’s about it. Please do not use this for anything. If you judge, remember, I wrote it on a flight with limited internet access with the goal of understanding some implementation details of an idea.
If you found this post helpful, please consider sharing to your network. I'm also available to help you be successful with your distributed systems! Please reach out if you're interested in working with me, and I'll be happy to schedule a free one-hour consultation.