Skip to main content

pysqltools

PySQLTools tries to ease the interaction between Python and SQL. The idea behind this project is to provide an easy framework to manage the interaction between this two languages. It allows dynamic queries management, using parameters in the SQL queries that can be later easily manipulated with the provided tools.

Install

you can install the latest distribution by pip install pysqltools

Current Features

Query Module

The query module provides a Query class to work with Query objects, which will allow to modify the SQL Queries on an easy way with the class methods, and easily access the sql string with the sql attribute of the objects.

To add parameters to the query, use {{parameter}} on the SQL String.

The current methods are:

  • ctes: Generator that yields the CTEs of the Query
  • selects: Generator that yields the Select statements of the Query
  • Windows: Generator that yields the Window Function contents of the query
  • tables: Generator that yields the detected tables on the query
  • parameters: Generator that yields all the parameters on the Query
  • format: allows to assign values to the parameters in the query. Current supported types are str, int, float, datetime.datetime, list[int, float, str] To call the format function, just call the parameters you have defined on your query. Example: query: select * from {{table_param}} limit 20

function call: query = Query(sql = sql).format(table_param = "MyTable")

Insert Module

More to be developed. For now, it contains a Generator generate_insert_query twith the following inputs:

  • df: pd.DataFrame containing the data we want to insert
  • table: name of the table we want to insert into
  • schema: name of the schema were the table is located
  • batch_size: How many rows on one insert query Note: if no table is provided, a parameter {{table}} will be automatically created on the Query object. It can be later changed using the .format() method.

The Generator yields Insert Queries (with batch_size rows) that can be iterated to execute.

Table Module

Allows to create tables on a SQL Database given a pandas DataFrame. Also contains the option to insert the data of the dataframe in the new table by calling the insert module

Delete Module

Contains the function delete_from_dataframe. This function allows to generate a Query object that will contain a SQL to delete all the rows in the target table that meet the conditions on the dataframe rows

Metadata

Release files for pysqltools 1.1.2

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

Source distribution (sdist)

Source distribution for pysqltools 1.1.2
File Size Uploaded Provenance Actions
pysqltools-1.1.2.tar.gz 10.9 kB Without provenance Details for pysqltools-1.1.2.tar.gz

Built distribution (wheel)

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

Total release size: 25.2 kB

Release files / pysqltools-1.1.2.tar.gz

Download URL pysqltools-1.1.2.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9fc05386154026ea708d0246755ec5a1b9afa4ab4bac54fc70a2ef8a232c0d1f
BLAKE2b-256 checksum
How to use checksums
955fa2de5b7d158c800749306853769b3b0e74afbd5304b1cfdf4be57291546b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.14 Darwin/27.0.0

Release files / pysqltools-1.1.2-py3-none-any.whl

Download URL pysqltools-1.1.2-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc4665cac4e9780ce8903089a140eba20a0125dd2ddd2c74a633ab9bd1ef1308
BLAKE2b-256 checksum
How to use checksums
1fcc1ebca2ac86892a5b6f8ad6b9868f6bd156aefeaceac3a5a9fe66dcd2d9cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.14 Darwin/27.0.0

Security for pysqltools 1.1.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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