Skip to main content

A simple utility tool that scan SQL files with queries separated by comments into python dicts.

Project description

SQLoad

A simple utility tool that scan SQL files with queries separated by comments into python dicts.

Usage

Given a file called queries.sql with the following content:

-- find-all-by-name
SELECT * FROM users WHERE name = :name

-- find-one-by-id
SELECT * FROM users WHERE id = 10 LIMIT 1

-- find-users-join-products
SELECT * FROM users u
    INNER JOIN products p ON u.id = p.user_id
    WHERE u.id = 1
    LIMIT 1

You can load those queries into dicts as follow:

from sqload import load

q = load('queries.sql')


assert q['find-all-by-name'] == "SELECT * FROM users WHERE name = :name"

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

sqload-0.1.0.tar.gz (1.7 kB view hashes)

Uploaded Source

Built Distribution

sqload-0.1.0-py3-none-any.whl (2.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page