Giter Club home page Giter Club logo

mini-sql-engine's Introduction

Mini-SQL-Engine

A mini SQL engine to parse and execute simple sql queries implemented in python

Description

  • files directory contains the database and its schema.
  • files/metadata.txt contains the schema of the database. Each table's schema is given between <begin_table> and <end_table>. The first line is the name of the table and others lines are field(column) names.
  • Data stored in each table is given as csv file in files directory of the same name as of the table. For example, the data of table 'table1' is given as 'table1.csv'.
  • Main source code is in src/mini_sql.py
  • Database contains only integer data.
  • Queries are entirely case insensitive.
  • Only simple queries can be performed. Nested queries are not allowed.
  • Error handling is implemented with sufficient error debugging details.

Run Query

Inside src directory, run python mini_sql.py "<sql_query>"

Valid queries

  • Normal select queries
    • select * from table1
    • select a, b from table1
  • Aggregate functions like min, max, avg, sum, count
    • select max(a), min(b) from table1
  • Select distinct values of a column
    • select distinct(a) from table1
  • Conditional select with at most two conditions joined by and or or
    • select a from table1 where a = 10
    • select a, b from table1 where a = c or b = 5
  • Table join and aliasing
    • select * from table1, table2
    • select a, t1.b, c, t2.d from table1 as t1, table2 as t2 where t1.b = t2.b and t2.d >= 0

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.