Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

blobbybilb/why-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note: This is a simple key-value store over HTTP, and not very useful except for quick prototyping. For a proper go embedded DB, take a look at gobble-db.


why?db

An extremely simple and lightweight HTTP key-value store. Written in go using fiber, because it's fast.

It can also use a Postgres DB as storage, while still having the same nice & simple HTTP key-value store.

Why?

Because I needed something simple to store/access data on a local server (for a project), without having to deal with an SQL or other database.

Basically, I wanted to be able to do this:

go run main.go  # Running on X.X.X.X:6010
fetch(`http://X.X.X.X:6010/set/example/${key}/${data}`)

fetch(f"http://X.X.X.X:6010/get/example/{key}") // data as text body

Then I also thought that it'd be nice to be able to use an SQL DB as storage for the key-value store (mostly to allow using a cloud SQL DB), so now it can also use a Postgres DB as storage.

Usage

It's very, very simple.

  1. Download, extract, open folder.

  2. go mod tidy, then go run .

  3. Make http requests. Routes:

    set (replaces value):
    GET /set/<category>/<key>/<value>/
    POST /set/<category>/<key>/     (raw POST body is used as value)
    
    add (appends to value):
    GET /add/<category>/<key>/<value>/
    POST /add/<category>/<key>/     (raw POST body is used as value)
    
    
    get:
    GET /get/<category>/<key>/      (gets stored value as response text)
    
    
    del (deletes value):
    GET /del/<category>/<key>/
    
    # Examples:
    curl http://127.0.0.1:5000/set/example/somekey/somevalue/
    curl http://127.0.0.1:5000/get/example/somekey/  # somevalue

Limitations

Yes.