🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

sqloader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqloader

A simple and extensible SQL migration and loader utility for Python.

pipPyPI
Version
0.1.1
Maintainers
1

sqloader

A lightweight Python utility for managing SQL migrations and loading SQL from JSON or .sql files. Supports common relational databases and is designed for simple, clean integration with any Python backend (e.g., FastAPI).

Installation

pip install sqloader

Features

  • âś… Easy database migration management
  • âś… Load SQL queries from .json or .sql files
  • âś… Supports MySQL and SQLite
  • âś… Clean API for integration
  • âś… Lightweight and dependency-minimized

Quickstart

from sqloader.init import database_init

config = {
    "type": "mysql",
    "mysql": {
        "host": "localhost",
        "port": 3306,
        "user": "root",
        "password": "pass",
        "database": "mydb"
    },
    "service": {
        "sqloder": "res/sql/sqloader/mysql"
    },
    "migration": {
        "auto_migration": True,
        "migration_path": "res/sql/migration/mysql"
    },
}

db, sqloader, migrator = database_init(config)

# Example usage
query = sqloader.load_sql("user_info", "user.get_user_by_id")
result = db.fetch_one(query, ['abc', 123])

SQL Loading Behavior

  • If the value in the .json file ends with .sql, the referenced file will be loaded from the same directory.
  • Otherwise, the value is treated as a raw SQL string.

Example JSON file user.json:

{
  "user": {
    "get_user_by_id": "SELECT * FROM users WHERE id = %s",
    "get_all_users": "user_all.sql"
  },
  "get_etc": "SELECT * FROM etc"
}

Keywords

sqloader

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts