Skip to main content

Small SQL helper utilities with optional external authsql.py config loading.

Project description

toolssql

Small SQL helper utilities (MySQL-focused) with flexible auth configuration.

Install

pip install toolssql

Auth config loading

This package will try to load CONNECTION_CONFIG and CONNECTION_CONFIG_DEFAULT from an authsql.py module/file in this order:

  1. AUTHSQL_MODULE env var (importable module path, e.g. myapp.authsql)
  2. Import authsql (works when your project root is on sys.path)
  3. AUTHSQL_PATH env var pointing directly to an authsql.py file (supports ~ and $HOME)
  4. Home directory fallbacks:
    • ~/authsql.py
    • ~/.authsql.py
    • ~/.config/authsql.py

Example config:

from typing import Dict, Any
CONNECTION_CONFIG: Dict[str, Any] = {
    'config1':
    {
        'host': 'localhost',
        'user': 'Analyst',
        'password': 'XXXXXXXXXXXXXXXXX',
        'database': 'Playground',
    },
    'config2':
    {
        'host': 'localhost',
        'user': 'Analyst2',
        'password': 'XXXXXXXXXXXXXXXXX',
    },
}

# default connection to be used, if nothing else is specified
CONNECTION_CONFIG_DEFAULT = "config1"

If none are found, it falls back to {} / None.

Important: Do not ship secrets inside this PyPI package. Keep authsql.py outside git.

Usage

from toolssql import MysqlConnect

db = MysqlConnect()  # uses loaded defaults if available
df = db.select_df("SELECT 1 AS one")
print(df)

Or inject config explicitly:

from toolssql import MysqlConnect

cfg = {
  "prod": {"host": "...", "user": "...", "password": "...", "database": "..."}
}
db = MysqlConnect(connection="prod", connection_config=cfg, connection_default="prod")

Project details


Download files

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

Source Distribution

toolssql-0.1.3.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

toolssql-0.1.3-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file toolssql-0.1.3.tar.gz.

File metadata

  • Download URL: toolssql-0.1.3.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for toolssql-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b6d4e9009015e8ffb6400c550ddbc9b0a83be7f6c10a3be247283c6987d00e86
MD5 5f3e4ebb7480e6b956b652d0aace4893
BLAKE2b-256 6518fc473a95fc9190def9a41fc2c6e8920c1eb1d089aa2c4dc0dc0255213328

See more details on using hashes here.

File details

Details for the file toolssql-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: toolssql-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for toolssql-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7af0c495b9a72318e13bf9bf16acf23368ae4e758759ced03c922dd58fb57785
MD5 2c1e2a1eac6aba5e3b41394ecccf74fe
BLAKE2b-256 9826b503991f2828f578921b1cce579e5f1f39da1f61bb632bd30af4b1f93484

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