Metadata-Version: 2.4
Name: pgbenchmark
Version: 0.0.2
Summary: [PLACEHOLDER] A Python package to benchmark Query performance and Comparison on PostgreSQL Database
Home-page: https://github.com/GujaLomsadze/pgbenchmark
Author: Elguja Lomsadze
Author-email: lomsadze.guja@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: psycopg2-binary==2.9.10
Requires-Dist: matplotlib==3.10.1
Requires-Dist: SQLAlchemy==2.0.40
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# pgbenchmark

`pgbenchmark` is a Python package to benchmark query performance on a PostgreSQL database. It allows you to measure the
execution time of queries over multiple runs, providing detailed metrics about each run's performance.

## [--- UNDER DEVELOPMENT ---]

## Getting Started

```shell
pip install pgbenchmark
```

---

```python
import psycopg2
from pgbenchmark import Benchmark

# Connect to PostgreSQL
conn = psycopg2.connect(
    dbname="",
    user="",
    password="",
    host="",
    port=""
)

# Create benchmark instance with desired number of Runs
num_runs = 100_000

# Create a Benchmark class
benchmark = Benchmark(db_connection=conn, number_of_runs=num_runs)

# Set .SQL file to fetch the query from for Benchmark
benchmark.set_sql("./test.sql")

# Or directly pass Raw SQL query
# benchmark.set_sql("SELECT 1;")

# Run the benchmark
benchmark.execute_benchmark()

# Get execution time summary
print("Execution Summary:", benchmark.get_execution_results())

# -----------------------------------------------

# Get execution timeseries using the generator
# (Useful if you want to visualize it as a table.
# "sent_at" is timestamp where `cursor.execute()` was initiated

for execute_data in benchmark.get_execution_timeseries():
    print(execute_data['sent_at'], execute_data['duration'])

```
