Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_sql_query_builder-0.1.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_sql_query_builder-0.1.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file python_sql_query_builder-0.1.3.tar.gz.

File metadata

File hashes

Hashes for python_sql_query_builder-0.1.3.tar.gz
Algorithm Hash digest
SHA256 986c1c882cbba6f372385f80829d8f1491999520bee8fe4e946a82a11f0fb8ce
MD5 75292bafc2289c2df18cde57db1219b4
BLAKE2b-256 707e313f29bbc8ae070115fe8bb6f21c2b8666f2982c7772d8bd9a7d90fabf1c

See more details on using hashes here.

File details

Details for the file python_sql_query_builder-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for python_sql_query_builder-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 44761b5a640d36994e42ad8d84868b04b690c01c09b23212095b73c3ae9b531f
MD5 2d2f71866fe8a6d202593ccb5371b751
BLAKE2b-256 bcc3be1e69b28faff94a07a37ca9ac63afdf7d0571830b9b9f4ca23261e8c655

See more details on using hashes here.

Supported by

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