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.4.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.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for python_sql_query_builder-0.1.4.tar.gz
Algorithm Hash digest
SHA256 97b97a3b9953a3118a9795d604f5653f494d58352d732192e7b11ef540020a70
MD5 542d4220b5ec749a8baa621056ca1e76
BLAKE2b-256 59e94743556a7bb4666fbb289b68f40d08553d4e128ccd2096af4b40daf24525

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_sql_query_builder-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5bccc8703e6d8f0c4a27c8fe5c615de3a731926fe0d64de7e501c5793b965871
MD5 95888b51ce03955a5f1f1490ca8fe392
BLAKE2b-256 4645d9b42dda6c31352dfd198edd7fb3f4ae9d898948ac61cf6a933f9de4b55f

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