Code Monkey home page Code Monkey logo

iplab_query_parser's Introduction

JSON based query Parser

This is an academic project for Internet Programming Lab, Department of Computer Science and Engineering, University of Dhaka

Installation

git clone https://github.com/maruf03/iplab_query_parser.git
cd iplab_query_parser

Windows

python.exe -m venv venv
venv\Scripts\activate.ps1
pip install -r requirements.txt

*nix (MacOS, Linux, BSD)

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run

python main.py

Configuration

Modify config.json file

{
    "sqlite": {
        "driver": "sqlite3",
        "url": "db/database.db"
    },
    "mysql": {
        "host": "localhost",
        "user": "root",
        "password": "",
        "database": "test"
    },
    "postgres": {
        "host": "localhost",
        "user": "postgres",
        "password": "",
        "database": "test"
    }
}

Query Format

The queries are pure JOSN objects. There are 5 types of queries.

CREATE Table Query

{
    "database": "sqlite", // other alternatives are "postgres" and "mysql"
    "type": "create",  
    "model": {
        "name": "Student",
        "schema": {
            "name": "string",
            "age": "int",
            "address": "string",
            "phone": "string",
            "email": "string"
        }
    }
}

INSERT Row Query

{
    "database": "sqlite",
    "type": "add",
    "model": {
        "name": "Student",
        "data": {
            "name": "Alif",
            "age": 25,
            "address": "Dhaka",
            "phone": "01922216159",
            "email": "[email protected]"
        }
    }
}

GET Row Query

{
    "database": "sqlite",
    "type": "get",
    "model": {
        "name": "Student",
        "where": {
            "name": "Alif"
        },
        "select": {
            "name": true,
            "age": true,
            "address": true
        }
    }
}

UPDATE Row Query

{
    "database": "sqlite",
    "type": "update",
    "model": {
        "name": "Student",
        "data": {
            "age": 22
        },
        "where": {
            "id": 1
        }
    }
}

DELETE Row Query

{
    "database": "sqlite",
    "type": "delete",
    "model": {
        "name": "Student",
        "where": {
            "name": "Alif"
        }
    }
}

Author

Maruf Al Alif Khan

iplab_query_parser's People

Contributors

maruf03 avatar

Stargazers

Fairuza Laila 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.