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.1

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.1
File Size Uploaded
pysqltools-1.1.1.tar.gz 11.5 kB Details

Built distribution (wheel)

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

Total release size: 25.8 kB

Release files / pysqltools-1.1.1.tar.gz

Download URL pysqltools-1.1.1.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ac2a307193ebca81a894c7819e2c0171a727c8181996487290bf8ce9f4c80dc0
BLAKE2b-256 checksum
How to use checksums
d244262cf32c05bb3844e2271546422fef9aaf9ddd5ae05c3953319a4a183128
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.11.5 Darwin/24.3.0

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

Download URL pysqltools-1.1.1-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
300ef2178ee9d2c48567b6fecdd57beae4691dd30e54d213f305350058b07950
BLAKE2b-256 checksum
How to use checksums
9552fed8bd6aa138911dd7476b2ceacd8325a7255834d23a31617716fe8d7313
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.11.5 Darwin/24.3.0

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

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