🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

python-sql-query-builder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-sql-query-builder

A fluent Python SQL query builder with support for joins, where clauses, inserts, updates, and more

0.1.4
Source
PyPI
Maintainers
1

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

Keywords

python-sql-query-builder

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts