Python bindings for DataPaths SQL engine
Project description
Database
DataPaths is an in-memory SQL database for relational data storage. Written in C/C++, it is designed to maximize storage capacity by compressing low-entropy columns. Developed from the start without external dependencies, the DataPaths library can be easily embedded in a wide range of projects.
Data Types
The following data types are currently available:
- SHORT: 16-bit signed int
- INT: 32-bit signed int
- LONG: 64-bit signed int
- FLOAT: 32-bit floating point number
- DOUBLE: 64-bit floating point number
- STRING: text data
- DATE: 2-bit calendar date stored as an integer offset from Jan 1, 1970
Table Configuration
Several methods for table configuration are available. The default method assumes no knowledge of data structure and attempts to optimize the table structure once a certain number of rows are available in the table:
CREATE TABLE(column1 TYPE, column2 TYPE,...)
An alternative approach is to explicitly specify which columns can be used as categories. This method requires some knowledge of the data to identify which table columns contain the least information:
CREATE TABLE(column1 TYPE [CAT NUM] , column2 TYPE [CAT NUM],...)
Finally, an option is available to configure the table using an existing data set. This procedure will read the CSV file to determine which columns should be used as categories:
CREATE TABLE(column1 TYPE, column2 TYPE,...) CONFIG FROM file_name
Loading Data
Data can be loaded from a standard CSV file using the following command:
LOAD TABLE FROM file_name
SELECT Query
The following is a general form of SELECT statement:
SELECT column1, column2, ... FROM table [JOIN join_table on table_col = join_col ] [WHERE condition1, condition2, ...] [ORDER BY column1 [DESC], column2 [DESC], ...]
Python Interface
Python bindings are available for interacting with the database in Python applications. Currently, the DataPaths module can be installed on Windows and Linux platforms for Python 3.11–3.14:
pip install datapaths
The package provides two main classes for interacting with the database:
DatabaseParser: executes database commands and SELECT queriesQuerySet: represents query results and provides accessors for rows, columns, and string data
DatabaseParser is the main class for interacting with the database and it can execute database configuration commands as well as SELECT queries. The following methods are available:
executeCommand(string): executes database commandexecuteSelect(string): execute SELECT command and returnQuerySetobject containing data results
QuerySet is the storage container for SELECT query results. The following methods are available:
getNumberOfRows(): returns number of rows of the resulting querygetNumberOfCols(): returns number of columns of the resulting querysetRow(int): set the current query rowgetString(int): get column entry as stringgetFloat(int): get column entry as floatgetInt(int): get column entry as integer
DataPaths library error handling is performed using exceptions mechanism. If invalid command is executed, an exception is thrown which is then translated into Python RuntimeError.
Python Example
The following code demonstrates how to load a 65 MB CSV file into the DataPaths Python module with just 35 MB of memory usage:
import urllib.request, datapaths
csvFile = "Electric_Vehicle_Population_Data.csv"
urllib.request.urlretrieve("https://data.wa.gov/api/views/f6w7-q2d2/rows.csv?accessType=DOWNLOAD", csvFile)
parser = datapaths.DatabaseParser()
parser.executeCommand("create table ev(vin string,county string,city string,state string,postalcode int,"
"modelyear short,make string,model string,type string,cafveligibility string,"
"electricrange short,legislativedistrict short,vehicleid string,"
"vehiclelocation string,electricutility string,censustract int)")
parser.executeCommand(f"load ev from {csvFile}")
res = parser.executeSelect("select * from ev where make = TESLA")
for i in range(res.getNumberOfRows()):
res.setRow(i)
print(f"VIN: {res.getString(0)} Model: {res.getString(7)}")
Software Errors
To report software errors and bugs, please contact support@datapaths.technology
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datapaths-1.0.1-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: datapaths-1.0.1-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 146.8 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71570753edd44684d14b80b20589917a3a172431adfc30fee6ee3525b2feb43c
|
|
| MD5 |
cdf8b11981c5d7668985ce3b58d38586
|
|
| BLAKE2b-256 |
da192a979c74628ede65b8e4b5c360d6ec2e0eab53c1e0bf4b5fbbb45ce6d8c2
|
File details
Details for the file datapaths-1.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: datapaths-1.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 297.3 kB
- Tags: CPython 3.14, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4eeeeff81916177c39d2b512d7c193c080ca2a9a003f03b858fd02aedcbae24
|
|
| MD5 |
0bbc9c124108508d60d7c6cba6e07af5
|
|
| BLAKE2b-256 |
55b76c927ad5430cde2e6b42eb462028d7b6c6c9506f01c73307a4b7262a210b
|
File details
Details for the file datapaths-1.0.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: datapaths-1.0.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 142.7 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f0f4b551304703b5e461b53af58de53c9f5666b358208fc3ccf47c3ca630c42
|
|
| MD5 |
0d416e45b7d30288072084614e3f5f34
|
|
| BLAKE2b-256 |
13b5d171d123ef01806b4a6e7298062a6f3c1ece61022e05095c0e370a016ee0
|
File details
Details for the file datapaths-1.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: datapaths-1.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 295.4 kB
- Tags: CPython 3.13, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd4fbf9cf00a7236763cecb464d101f86b0651f5959be1ad1aff578676040805
|
|
| MD5 |
ff30c5cd874bfd0189272684532789a5
|
|
| BLAKE2b-256 |
3d6bf1bc9d7c66a5b2505657711e3b4b1356e96db37fea0d4a8c1ea215f2d245
|
File details
Details for the file datapaths-1.0.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: datapaths-1.0.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 142.7 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3351957f8cf0eb8bed316eae65df261ccd9b41eef7bb7289c31d8d3571c283f6
|
|
| MD5 |
df4e1d5126e09c4db0de891649102c28
|
|
| BLAKE2b-256 |
e95e047a9c63e725ad50cc2b910f3caa2e99f0dbda84807fdc0cc638d4762234
|
File details
Details for the file datapaths-1.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: datapaths-1.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 295.4 kB
- Tags: CPython 3.12, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71d1744aaf5a5fa2e5019bf570161fcbe00e2864e7c138d1659a7eb45b047abc
|
|
| MD5 |
8c6933b14684bc73ea97121037c096ba
|
|
| BLAKE2b-256 |
c9a937410aab860688a84fd87da7dfc710a448e5e418c5c06fbef49598a5ab64
|
File details
Details for the file datapaths-1.0.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: datapaths-1.0.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 142.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b23008d94a5217e948f422c035747b186b07cb704e188c941cb1b05403d1488a
|
|
| MD5 |
0db7f781ae4a4183e0bcc5edec66f23b
|
|
| BLAKE2b-256 |
06e82ff2aec361b682f99472fed8aa3967b4a1c288e20ce8151b1ed75a19d4dd
|
File details
Details for the file datapaths-1.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: datapaths-1.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 293.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d9bf9f90edfe660072618b9fbcbb1bfb06aa6cb31f5a2050a854317a5dc2e8d
|
|
| MD5 |
ae2c2df01ca26c17b3c70cba946afdce
|
|
| BLAKE2b-256 |
7369a8abbf2dff90f785ad72df68c623a94cee0c3ce535c280497baf04829d44
|