A fluent Python SQL query builder with support for joins, where clauses, inserts, updates, and more
Project description
SQLQuery
A simple Python class that enables you to build SQL queries using a fluent, chainable interface. This tool is perfect for developers who want to generate SQL statements programmatically without writing raw SQL strings manually.
Features
- Intuitive, chainable API for building SQL queries
- Supports:
- SELECT: SELECT, SELECT DISTINCT
- Data Manipulation: INSERT INTO, UPDATE, DELETE FROM
- Conditions: WHERE, AND, OR, IN, HAVING
- Grouping & Ordering: GROUP BY, ORDER BY, LIMIT, OFFSET
- Joins: LEFT JOIN, RIGHT JOIN, INNER JOIN, FULL JOIN
- Transactions & Savepoints: COMMIT, ROLLBACK, SAVEPOINT
- Table Operations: CREATE TABLE, DROP TABLE, ALTER TABLE, RENAME TABLE, ADD COLUMN, DROP COLUMN
- Index Operations: CREATE INDEX
- Permissions: GRANT, REVOKE
- Set Operations: UNION, INTERSECT, EXCEPT
- Conflict Handling: ON CONFLICT DO NOTHING
- Value Operations: VALUES, IN CLAUSE
Installation
You can install this package via PIP: pip install python=sql-query-builder
Usage
from sql_query_builder import SQLQueryBuilder
query = (
SQLQueryBuilder()
.select('id', 'name', 'email', distinct=True)
.from_table('users')
.where("age > 21")
.and_where("city = 'New York'")
.order_by('name')
.limit(10)
)
print(query.build())
# Output:
# SELECT DISTINCT id, name, email FROM users WHERE age > 21 AND city = 'New York' ORDER BY name LIMIT 10
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_sql_query_builder-0.1.3.tar.gz.
File metadata
- Download URL: python_sql_query_builder-0.1.3.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
986c1c882cbba6f372385f80829d8f1491999520bee8fe4e946a82a11f0fb8ce
|
|
| MD5 |
75292bafc2289c2df18cde57db1219b4
|
|
| BLAKE2b-256 |
707e313f29bbc8ae070115fe8bb6f21c2b8666f2982c7772d8bd9a7d90fabf1c
|
File details
Details for the file python_sql_query_builder-0.1.3-py3-none-any.whl.
File metadata
- Download URL: python_sql_query_builder-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44761b5a640d36994e42ad8d84868b04b690c01c09b23212095b73c3ae9b531f
|
|
| MD5 |
2d2f71866fe8a6d202593ccb5371b751
|
|
| BLAKE2b-256 |
bcc3be1e69b28faff94a07a37ca9ac63afdf7d0571830b9b9f4ca23261e8c655
|