Skip to main content

SQL+Python

A collection of utils to effortlessly and reliably interact between Python and your SQL database — purpose‑built for time‑series workflows. This package streamlines reading, writing, and maintaining SQL tables using familiar Python structures like pandas DataFrames, dictionaries, and other Python objects. It’s user-friendly, strict about data consistency, and tuned for time-series data pipelines. Intended for MariaDB/MySQL via SQLAlchemy - pre-configured docker environment included.

Design Principles

  • Predictable schemas: deterministic dtype mapping and optional auto-alter
  • Strong safeguards: explicit checks, clear assertions, and helpful errors
  • Pandas-friendly: minimal friction between DataFrame types and SQL
  • Maintainability: composable helpers for upload, fetch, and schema operations

Key Features

  • Focus on time-series data

    • Append-only patterns with optional “update latest” logic
    • Automatic handling of date/symbol index columns
    • Fast retrieval by symbol and date with optional indexing
    • Utilities to query by symbol(s), fetch latest dates, and union columns across tables
  • Works with your data structures

    • Upload pandas DataFrames with automatic dtype mapping
    • Store/retrieve dictionaries as rows
    • Persist arbitrary Python objects via pickling (e.g., models, configs)
    • Minimal boilerplate for table creation and updates
    • Smart dtype defaults for SQL schema generation
  • Safety and consistency checks

    • NaN/Inf coercion and validation for key columns
    • Duplicate/consistency guards when updating recent rows
    • Table introspection: add missing columns automatically (optional)
    • Environment validation and connection checks

Typical Use Cases

  • Maintain historical time-series data on a symbol-level (prices, indicators, metrics)
  • Incrementally update tables from pandas pipelines
  • Keep per-symbol metadata and snapshots
  • Store models or transforms in SQL as versioned pickles

Installation

  • Python: 3.12+
  • Installed packages: sqlalchemy, pandas etc.
  • Optional: Docker to use the docker compose environment that is set up to work wiht the utils - batteries included

Create/activate your virtualenv, then install your project’s dependencies as usual with pip inside the virtualenv. Run docker compose up in the project root to start the MariaDB container with the default environment variables.

Environment Variables

  • Standard DB credentials (e.g., user, password, host, port, database) loaded from your .env
  • A default setup for Docker is included
  • Built-in validation for host configuration; safe fallbacks if misconfigured

Quick Start

The main functions are listed below.

  • upload_df(): DataFrame uploads

    • Auto-creates tables with sensible column types (numeric as DOUBLE, categoricals as TEXT, datetimes as DATETIME) using create_table()
    • Optional table alteration to add newly appearing DataFrame columns
    • Optional enforcement of non-null date/symbol keys with configurable behavior
    • When uploading time-series data and using “update latest,” only the newest overlapping row(s) are replaced; older history remains intact
  • upload_dict(): Dictionary uploads

    • Keys become columns; can define a symbol column for idempotent updates
  • upload_object(): Object uploads

    • Serialize Python objects via pickle and store them in LONGBLOB columns
  • Retrieval helpers

    • get_symbol_data() or get_df_symbols_data(): Get time-series for a single symbol or multiple symbols
    • get_all_symbol_data(): Fetch all tables for a symbol in one go
    • get_existing_rows(): Inspect availability (tables exist, rows > 0), and compute the union of columns across tables

Metadata

Release files for SQLplusPython 0.2.0

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

Source distribution (sdist)

Source distribution for SQLplusPython 0.2.0
File Size Uploaded
sqlpluspython-0.2.0.tar.gz 33.0 kB Details

Built distribution (wheel)

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

Total release size: 69.1 kB

Release files / sqlpluspython-0.2.0.tar.gz

Download URL sqlpluspython-0.2.0.tar.gz
Size 33.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1e512cca02db4bf1cc21f9967f346f79cd575435c6b1c067a0e01af03fa8950a
BLAKE2b-256 checksum
How to use checksums
80b5abe97d9432766b3427c5ebbe8e619bd88804f0239afeb814dc135f5bce86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2025.

Transparency log

Release files / sqlpluspython-0.2.0-py3-none-any.whl

Download URL sqlpluspython-0.2.0-py3-none-any.whl
Size 36.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a566c307c6eff71ed70c98fa01213a315a01c98dc91a061df80172518bb99b80
BLAKE2b-256 checksum
How to use checksums
e25853d39486acc7dc8c1aff48b679484dafb3caafafaa43f2e75a0f32b66967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

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