Git Product home page Git Product logo

sweatdb's Introduction

sweatdb

About sweatDB

SweatDB is a cutting-edge database management system that offers a simplified syntax, making it an ideal choice for users seeking an easier alternative to SQL. With SweatDB, you can efficiently organize, store, and retrieve your data without the complexities associated with traditional database systems.

Installation

pip install sweatDB

SQL Comparison to sweatDB

SQL

CREATE TABLE people (Name TEXT,
    Location TEXT);
INSERT INTO people (
    Name,
    Location,
    Name,
    Location) 
VALUES ('Dorito man',
    'Dallas Texas',
    'John Adams',
    'New york New york');
SELECT Name FROM people WHERE Name like 'D%';

Python

from sweatDB import actions as sdb

sdb.create('people')

data = {
    '!Name!Dorito': 'man',
    '!Location!Dorito': 'Dallas, Texas',
    '!Name!John': 'Adams',
    '!Location!John': 'New York, New York'
}

for key, value in data.items():
    sdb.add('people', key, value)

results = sdb.view('people', 'iv', '!Name!D')
print(results)

First example Usage

from sweatDB import actions as sdb

sdb.create('test')
print(sdb.view('test', 'info'))

for x in range(100):
    sdb.add('test', f'item{x}', x * 100)

print(sdb.view('test', 'count'))
print(sdb.view('test', start=50, end=60))

sdb.delete('test', delete_type='db')
Preview

image

Second example Usage

from sweatDB import actions as sdb

dbs = ['inventory', 'display', 'orders']

for db in dbs:
    sdb.delete(db, delete_type='db')
    sdb.create(db)

fruits = {'Apple': 9, 'Pear': 3, 'Banana': 20}
for fruit, quantity in fruits.items():
    sdb.add('inventory', f'fruits-{fruit}', quantity)

vegetables = {'Broccoli': 5, 'Carrot': 10, 'Cauliflower': 20}
for vegetable, quantity in vegetables.items():
    sdb.add('inventory', f'vegetables-{vegetable}', quantity)

items = sdb.view('inventory', 'iv')
for item in items.split("\n")[:-1]:
    item, value = map(str, item.split(" "))
    sdb.add('display', item.split("-")[1], 1)
    sdb.edit('inventory', item, int(value) - 1)

print(f"On display:\n{sdb.view('display', 'items')}")
print(f"In inventory:\n{sdb.view('inventory', 'iv')}")

orders = {'vegetables-Broccoli': 2, 'vegetables-Carrot': 5, 'fruits-Apple': 3, 'fruits-Banana': 10}
for order, quantity in orders.items():
    sdb.add('orders', order, quantity)

print(f"Current orders:\n{sdb.view('orders', 'iv')}")

for order in sdb.view('orders', 'iv').split("\n")[:-1]:
    item, value = map(str, order.split(" "))
    sdb.edit('inventory', item, int(sdb.view('inventory', 'item', item)) - int(value))
    sdb.delete('orders', item)

print(f"Inventory after fulfilling orders:\n{sdb.view('inventory', 'iv')}")

vegetables_inventory = ''.join([f"{x.replace('vegetables-', '')}\n" for x in sdb.view('inventory', 'iv', 'vegetables-').split('\n')])[:-1]
fruits_inventory = ''.join([f"{x.replace('fruits-', '')}\n" for x in sdb.view('inventory', 'iv', 'fruits-').split('\n')])[:-1]

print(f"Vegetables in inventory:\n{vegetables_inventory}")
print(f"Fruits in inventory:\n{fruits_inventory}")
Preview

image

Website example

Gif Preview

siteexample

sweatdb's People

Contributors

0xsweat avatar birdlinux avatar

Stargazers

 avatar

Watchers

 avatar

sweatdb's Issues

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.