Skip to main content

This module is meant to be used in small to medium scale applications and makes SQLite3 Read and Write functions python. Changing every DataBase, Table and Row object to classes.

Quickstart

pip install data3
  1. To get the entire DataBase use:
    import data3
    
    with data.open() as db:
      pass
    
    Alternatively, you can use the following code to get just one table:
    with data.open(table="YourTable") as table:
       pass
    
    Data3 will automatically open and close connections for you.
  2. Index a table with databaseObject["YourTable"]
  3. Read data with table.get(), you can narrow down your search by using table.get(column=value) or use table.first() to get only the first value
  4. Adding/updating/removing data works as following: table.add(column=value, column=value...), table.update(column=value)(column=value, column=value...), table.remove(column=value).
  5. By adding, finding or updating data you will be returned a rowObject which you can index with columns to find one value, you can use rowObject.pk to get just the primaryKey, it can also be converted to a Dict or you can edit your row by using rowObject["column"] = value or rowObject(column=value, column=value)

Example

import data3

with data3.open(table = "matches") as table:
    for row in table.find(): # This will loop through every row as a rowObject.
        row["started"] = True # A row object can be changed with a set architecture for a single column.
        row(started = True) # Or you can call it for multiple.
    
    table.update(5)(started = False) # Here no key is provided, data3 will search for a primaryKey column or use the first column to find "5". As the table.update function will return another function in which you can specify every column and value you want to change.

    table(id = 90, started = False) # You can call a table to add a value or use "table.add".

    print(table.first(3)["started"]) # You can get one column like this also.

    with table.pause(): # Pause will temporarily close the connection and re-open it once you're done, useful when doing large computations that don't require reading the file.
        print("Free from the database.")

    print("Back to reading and writing.")

    table.remove(3) # Here no key is provided, data3 will search for a primaryKey column or use the first column to find "3". If you do want to specify a column you can use .remove(column = value).

Edit default values

import data3

# These are the default values and you can edit them accordingly
data3.path = './'
data3.defaultFile = "data"
data3.fileExtension = ".db"
data3.defaultTimeout = 10

# This is the default onError function, which you can modify
def onError(error, cmd):
    print(f"[Error\t] {error}\n[input\t] {cmd}")
data3.onError = onError

Release files for data3 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for data3 1.0.1
File Size Uploaded
data3-1.0.1.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for data3 1.0.1
File Interpreter ABI Platform
data3-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / data3-1.0.1.tar.gz

Download URL data3-1.0.1.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dd3ccbe89eaed2147f8505e180b45e61e15f451424c987137a41b8425b7f2601
BLAKE2b-256 checksum
How to use checksums
a5e708a3094ff862d7b4a9b787b15b0bc484ca0fd1b09333c221e086100a10c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.11

Release files / data3-1.0.1-py3-none-any.whl

Download URL data3-1.0.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e06854269c87e0c5bff52a6255ed6e3f8ed72174eaed573bcaadf2c5e56e1d94
BLAKE2b-256 checksum
How to use checksums
0ff7b7a256948634a0cee4d9a0397dbf2c557dcdbaeb0f331571f779b16f0ae1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.11

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page