Giter Site home page Giter Site logo

dumbdb's Introduction

DumbDB

Database for Dummies. A simple, easy-to-use, and lightweight database for small projects. It is so simple a child could use it.

API

The API is very simple, it has only 5 commands, and it's very easy to use.

The following commands are available: SET, GET, DELETE, CONTAINS, CLEAR. All commands are case-insensitive. Comments are also supported, they start with two dashes and end with a newline. The Database has 4 data types: unsigned integer, string, boolean, and NULL. NULL is a special data type that represents the absence of a value. It can only be returned by the GET command when the key does not exist. Setting a key to NULL is equivalent to deleting the key. You are able to chain commands together, multiple commands can be written in a single line, separated by a semicolon. As an example, SET 0 "Hello"; GET 0 will set the key 0 to the value "Hello" and then get the value of the key 0.

Dumb Query Language

Values are ONLY strings. Keys are ONLY unsigned integers. TRUE and FALSE are booleans, and only returned by the CONTAINS command. NULL is a special data type that represents the absence of a value, and only returned by the GET command when the key does not exist.

-- This is a comment!
SET key value
GET key
DELETE key
CONTAINS key
CLEAR

SET

Sets a value to a key. Permission Level: WRITE If the key already exists, it will overwrite the value. If the key does not exist, it will create a new key with the value. If the value is NULL, it will delete the key.

GET

Gets a value from a key. Permission Level: READ If the key does not exist, it will return NULL.

DELETE

Deletes a value from a key. Permission Level: WRITE If the key does not exist, it will do nothing.

CONTAINS

Checks if a key exists. Permission Level: READ If the key exists, it will return TRUE, otherwise, it will return FALSE.

CLEAR

Deletes all keys and values from the database. Permission Level: ADMIN This action is dangerous and permanent, use with caution.

TRUE and FALSE

TRUE and FALSE are the only two boolean values in the database. They are case-insensitive.

NULL

NULL is a special data type that represents the absence of a value. It can only be returned by the [GET] command when the key does not exist. Setting a key to NULL is equivalent to deleting the key.

Examples

Example (Python)

from dumbdb import DumbDB

class Message:
    def __init__(self, content: str, user_id: int):
        self.content = content
        self.user_id = user_id
    def __str__(self):
        return f"Message(content={self.content}, user_id={self.user_id})"

db = DumbDB[Message]("messages")
db.set(0, Message("Hello", 0))
print(db.get(0)) # Message(content="Hello", user_id=0)
db.delete(0)
print(db.contains(0)) # False
db.clear()

Example (Rust)

use dumbdb::DumbDB;

#[derive(Debug)]
struct Message {
    content: String,
    user_id: u64,
}

fn main() {
    let mut db = DumbDB::<Message>::new("messages");
    db.set(0, Message { content: "Hello".to_string(), user_id: 0 });
    println!("{:?}", db.get(0)); // Message { content: "Hello", user_id: 0 }
    db.delete(0);
    println!("{}", db.contains(0)); // false
    db.clear();
}

dumbdb's People

Contributors

atomicgamer9523 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

phabr1945

dumbdb's Issues

optional extra features

also, the clear command should be able to have an argument all to clear everything, or range to clear a range of keys, or an except to clear all but some keys
EX:
clear range 14938, 3yu3i, nf83n, 3329h
clear all except 289hd, 478fs
clear all

These extra features would have to be imported from a module.
EX: (in python)
from DDB import extra.features
(extra.features would not be called by * because idk. I know this from my 4d shapes in python shenanigans ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.