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
Metadata
Release files for cosevadb 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cosevadb-0.0.3.tar.gz | 9.7 kB | Without provenance | Details for cosevadb-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cosevadb-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for cosevadb-0.0.3-py3-none-any.whl |
Total release size: 18.8 kB
Release files / cosevadb-0.0.3.tar.gz
| Download URL | cosevadb-0.0.3.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
465e1ab569629cbfa89e801845b5f9850e3b8e195a8ea24c80b1361fe2cc578f
|
|
BLAKE2b-256 checksum How to use checksums |
295bc26885afc14aee6d9a9c102804f44193de6a75fd27500131f6eba0c98b12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / cosevadb-0.0.3-py3-none-any.whl
| Download URL | cosevadb-0.0.3-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53086ac3303b58ae2c7a1e51b50786b38c86603e56e81bf22d9566da7cc166c6
|
|
BLAKE2b-256 checksum How to use checksums |
05d94fc6a71ec52cfc671a549859c659d511167d1e7cc118e91f7eefd1639fb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for cosevadb 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.