Skip to main content

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 queries
  • QuerySet: 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 command
  • executeSelect(string): execute SELECT command and return QuerySet object 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 query
  • getNumberOfCols(): returns number of columns of the resulting query
  • setRow(int): set the current query row
  • getString(int): get column entry as string
  • getFloat(int): get column entry as float
  • getInt(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(1)}")

Software Errors

To report software errors and bugs, please contact support@datapaths.technology

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

datapaths-1.0.0-cp314-cp314-win_amd64.whl (146.8 kB view details)

Uploaded CPython 3.14Windows x86-64

datapaths-1.0.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (297.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

datapaths-1.0.0-cp313-cp313-win_amd64.whl (142.8 kB view details)

Uploaded CPython 3.13Windows x86-64

datapaths-1.0.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (295.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

datapaths-1.0.0-cp312-cp312-win_amd64.whl (142.7 kB view details)

Uploaded CPython 3.12Windows x86-64

datapaths-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (295.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

datapaths-1.0.0-cp311-cp311-win_amd64.whl (142.0 kB view details)

Uploaded CPython 3.11Windows x86-64

datapaths-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (293.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file datapaths-1.0.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: datapaths-1.0.0-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

Hashes for datapaths-1.0.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 092a2506d4aa87600d3d80eb43a19cd37b7efad29a743da9915f37b7a1714e35
MD5 068992e895002f4e0605408a3e736637
BLAKE2b-256 f72beffbd610076fdb59710db2ba96d36c1bea9cf076ecebf92df3de5d17ab73

See more details on using hashes here.

File details

Details for the file datapaths-1.0.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for datapaths-1.0.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d42a7bf305d6b9c6aa071630f801038087e986e0910a6cdac957e72d1d3f83e3
MD5 e8dcbe6f41a50d89a198a7692b052dec
BLAKE2b-256 6bf086ba54415012beb0df799279ea60f75f82e29438acf6ca15ff62342fbe55

See more details on using hashes here.

File details

Details for the file datapaths-1.0.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: datapaths-1.0.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 142.8 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

Hashes for datapaths-1.0.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a2e3d5bff82fc12fdd1c9dce12997a64407e3e9c4422e59d43d227dc53e984df
MD5 d3300477602bd4b0978bb0d050cdb049
BLAKE2b-256 55a6e63fa82713e81712c0288f55b402a7cb75cb47e5e2499542176c3012eaa8

See more details on using hashes here.

File details

Details for the file datapaths-1.0.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for datapaths-1.0.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 77e2f3240a160574579786d03c62c4ab66650965f301ff04048bd1963761fbad
MD5 974aa12ead4fa3db142225867d344812
BLAKE2b-256 daf87fbc76bce67488c9f34413bd5f53b873b913a82fad8241f78dd8672feb1e

See more details on using hashes here.

File details

Details for the file datapaths-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: datapaths-1.0.0-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

Hashes for datapaths-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e490a2e2fb533a622b8f04171221630d4b514df4a450024707679261b7d58144
MD5 93c378b7e95ab83194628375649665f2
BLAKE2b-256 314ccd85f60460303a2b2665a275470d9ae788ddae1f12356c498d5a13c1c435

See more details on using hashes here.

File details

Details for the file datapaths-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for datapaths-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8eac75f0e8491bb698993388ab0faf78112395a88c719ed907e00cec7af63843
MD5 8036ecfc45cb36d8d0d782db8a2cabed
BLAKE2b-256 60e4f81805c4cbffc4f7cfc3e4fdf795ba00a1f5ec62a193128c68ca69636796

See more details on using hashes here.

File details

Details for the file datapaths-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: datapaths-1.0.0-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

Hashes for datapaths-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2be6623929a3ff3129f99242530185deda82ec40b618420bbee841d454e4da5c
MD5 b600bc39ab024223296c301521e3ff90
BLAKE2b-256 c780205c8bd8ff9c450b67e9ddbb9745fcdb895e022dc986189a2d5a68cabcee

See more details on using hashes here.

File details

Details for the file datapaths-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for datapaths-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d7d4c4114298d03041185975c73eca1ff37196aac7a72e2209047e08ce17854
MD5 9464e9213ed18f7249b173ba2577aa31
BLAKE2b-256 3cedb2d8fb1736d1f31792b5e3b6101f87ec3786efd11a5087b1ace6f222bb7a

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