Skip to main content

Light weight SQL database designed to manage data in csv format

Project description

CosevaDB - Comma Separated Values DB

CosevaDB is a light weight SQL database designed to store, retrieve and manage data in csv format.

Targets are,

  • Apps that require SQL DB or external DB server
  • Apps that need lightweight replacement for under-utilised heavy-weight DBs such as oracle, MySQL
  • Those who need a SQL processor and DB to manage existing csv data files

View detailed description on www.github.com/ppml38/cosevadb

Features:

  • Written purely in python
  • No external dependencies

Its a best practice to organise folders and csv files i.e., Databases and tables in below structure

database_name/
      table_name.csv
      table_header.csv
      ...

And to query the database like below

cosevadb.query("select name from path/to/database_name/table_name.csv, path/to/database_name/table_header.csv where role='Manager' & salary >= 5000")

However it is not mandatory to follow. you can pass the path of any csv file to parse.

How to install

pip install cosevadb

Usage

from cosevadb import cosevadb
cosevadb.query("select name,age from data/passengers.csv,data/header.csv where native='USA'")

Return format

[sqlcode,'<message>',[result list / empty list]]

SQL return codes

SQL Code Description
1 Empty result set
0 Success with atleast one result
-2 Unexpected character on position <index>
-3 Unexpected character on where clause position <index>
-4 Unsupported operator in where clause
-5 Non numeric operand with arithmatic operator <operator>
-6 Non boolean operand(LHS) with logical operator <operator>
-7 Non boolean operand(RHS) with logical operator <operator>
-8 Operator ! must be followed by =
-9 Unbalanced paranthesis on LHS of operator <operator>
-10 Unbalanced paranthesis on RHS of operator <operator>
-11 No field <fieldname> found in header file
-12 Value for variable <variablename> is missing in atleast one row
-13 Where clause condition returns non-boolean result
-14 Incomplete condition in where clause

Reserved words

Keywords
SELECT
FROM
WHERE

Operators supported

Operator type Operators
Arithmatic operators +, -, *, /, %
Comparison operators >, <, >=, <=, =, !=
Logical operators &, |

Operator precedence (in order from high to low)

Operator precedence
%
/
*
+
-
<,<=
>,>=
!=
=
&
|

File formats

Comma seperated value(.csv) files.

Instructions

  • String values should be within ''
  • A file with headers(Comma separated) should be passed along with csv data file
  • As of now only select operations implemented
  • Comparison operator '=' is used instead of '=='
  • Expression evaluation will use BODMAS as you studied in school. i.e., It has individual operator precedence unlike python or java. (ex): '9-7+1' will result '1' where python eval() will return 3

Licence

MIT Licence. Contributions are welcome

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cosevadb-0.0.3.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cosevadb-0.0.3-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file cosevadb-0.0.3.tar.gz.

File metadata

  • Download URL: cosevadb-0.0.3.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for cosevadb-0.0.3.tar.gz
Algorithm Hash digest
SHA256 465e1ab569629cbfa89e801845b5f9850e3b8e195a8ea24c80b1361fe2cc578f
MD5 3bece2d398cd1122d5d1d3634c2a75d5
BLAKE2b-256 295bc26885afc14aee6d9a9c102804f44193de6a75fd27500131f6eba0c98b12

See more details on using hashes here.

File details

Details for the file cosevadb-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: cosevadb-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for cosevadb-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 53086ac3303b58ae2c7a1e51b50786b38c86603e56e81bf22d9566da7cc166c6
MD5 60f77d5921aa6eb109f5b56fcc29a7a8
BLAKE2b-256 05d94fc6a71ec52cfc671a549859c659d511167d1e7cc118e91f7eefd1639fb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page