Giter VIP home page Giter VIP logo

austindb's Introduction

austinDB

image

Installing system packages, setting up SQL databases, and adding 10 more imports to your project is for chumps. What's an ORM? Who cares. Let's just use JSON files for our databases.

Usage

A basic database can be setup with a table like this:

import austinDB
db = austinDB.Database("my_database.json")
db.create("dogs", ["name", "age", "breed"])
dogs = db.read("dogs")

Create a row like this:

dogs.create(["Mose", 1, "Aussie mix"])

Read all matching rows in any of the following ways:

dogs.read() # For all rows
dogs.read(["name"]) # For all names
dogs.read(["breed"], ["name"], [(lambda name: name == "Mose")]) # For all breeds where name is Mose
dogs.read(["breed"], ["name", "age"], [(lambda name: name == "Mose"), (lambda age: age < 5)]) # Multiple conditions!

Update a row like this:

dogs.update(["age"], [2], ["name"], [(lambda name: name == "Mose")]) # Update age to 2

Delete a row like this:

dogs.delete(["name"], [(lambda name: name == "Mose")]) # Bye Mose!

Tables can be dropped like this:

db.delete("dogs")

You can do cool stuff like this too:

db.create("dogs", ["name", "owner_name"])
dogs = db.read("dogs")
dogs.create(["Mose", "Austin"])
dogs_result = dogs.read(["owner_name"], ["name"], [(lambda name: name == "Mose")])
mose_owner = dogs_result[0][0] # 0th row, 0th field

db.create("owners", ["name", "favorite_color"])
owners = db.read("owners")
owners.create(["Austin", "orange"])
owners_result = owners.read(["favorite_color"], ["name"], [(lambda name: name == mose_owner)])
favorite_color = owners_result[0][0] # Gets us "orange"!

So intuitive! Why would you do it any other way?

austindb's People

Contributors

austinkilduff avatar

Watchers

 avatar

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.