python-python-sql
Port variant v12
Summary Library to write SQL queries (3.12)
Package version 1.5.1
Homepage https://pypi.org/project/python-sql/
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v11
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 06 JUN 2024, 00:12:24 UTC
Port created 22 OCT 2023, 16:37:00 UTC
Subpackage Descriptions
single python-sql ========== python-sql is a library to write SQL queries in a pythonic way. Nutshell -------- Import:: >>> from sql import * >>> from sql.aggregate import * >>> from sql.conditionals import * Simple selects:: >>> user = Table('user') >>> select = user.select() >>> tuple(select) ('SELECT * FROM "user" AS "a"', ()) >>> select = user.select(user.name) >>> tuple(select) ('SELECT "a"."name" FROM "user" AS "a"', ()) >>> select = user.select(Count(Literal(1))) >>> tuple(select) ('SELECT COUNT(%s) FROM "user" AS "a"', (1,)) >>> select = user.select(user.name, distinct=True) >>> tuple(select) ('SELECT DISTINCT "a"."name" FROM "user" AS "a"', ()) >>> select = user.select(user.id, user.name) >>> tuple(select) ('SELECT "a"."id", "a"."name" FROM "user" AS "a"', ()) Select with where condition:: >>> select.where = user.name == 'foo' >>> tuple(select) ('SELECT "a"."id", "a"."name" FROM "user" AS "a" WHERE ("a"."name" = %s)', ('foo',)) >>> select.where = (user.name == 'foo') & (user.active == True) >>> tuple(select) ('SELECT "a"."id", "a"."name" FROM "user" AS "a" WHERE (("a"."name" = %s) AND ("a"."active" = %s))', ('foo', True)) >>> select.where = user.name == user.login >>> tuple(select) ('SELECT "a"."id", "a"."name" FROM "user" AS "a" WHERE ("a"."name" = "a"."login")', ()) Select with join:: >>> join = user.join(Table('user_group')) >>> join.condition = join.right.user == user.id >>> select = join.select(user.name, join.right.group) >>> tuple(select) ('SELECT "a"."name", "b"."group" FROM "user" AS "a" INNER JOIN "user_group" AS "b" ON ("b"."user" = "a"."id")', ()) Select with multiple joins:: >>> join1 = user.join(Table('user')) >>> join2 = join1.join(Table('user')) >>> select = join2.select(user.id, join1.right.id, join2.right.id) >>> tuple(select) ('SELECT "a"."id", "b"."id", "c"."id" FROM "user" AS "a" INNER JOIN "user" AS "b" INNER JOIN "user" AS "c"', ()) Select with group_by:: >>> invoice = Table('invoice') >>> select = invoice.select(Sum(invoice.amount), invoice.currency, ... group_by=invoice.currency) >>> tuple(select) ('SELECT SUM("a"."amount"), "a"."currency" FROM "invoice" AS "a" GROUP BY "a"."currency"', ()) Select with output name:: >>> tuple(user.select(user.name.as_('First Name'))) ('SELECT "a"."name" AS "First Name" FROM "user" AS "a"', ()) Select with order_by:: >>> tuple(user.select(order_by=user.date)) ('SELECT * FROM "user" AS "a" ORDER BY "a"."date"', ()) >>> tuple(user.select(order_by=Asc(user.date))) ('SELECT * FROM "user" AS "a" ORDER BY "a"."date" ASC', ()) >>> tuple(user.select(order_by=(user.date.asc, user.id.desc))) ('SELECT * FROM "user" AS "a" ORDER BY "a"."date" ASC, "a"."id" DESC', ()) Select with sub-select:: >>> user_group = Table('user_group') >>> subselect = user_group.select(user_group.user, ... where=user_group.active == True)
Configuration Switches (platform-specific settings discarded)
PY311 OFF Build using Python 3.11 PY312 ON Build using Python 3.12
Package Dependencies by Type
Build (only) python312:dev:standard
python-pip:single:v12
autoselect-python:single:standard
Build and Runtime python312:primary:standard
Download groups
main mirror://PYPIWHL/05/15/c76fa41233cc8e426ca45cd802aae5a862df9f104c709e9856bf6e0d18b7
Distribution File Information
5a62c98cc9603b21b171fd84a57c37f1c0d77394398646670342b476a67ed8f1 43571 python_sql-1.5.1-py3-none-any.whl
Ports that require python-python-sql:v12
python-trytond-account-asset:v12 Tryton module for assets management (3.12)
python-trytond-account-invoice:v12 Tryton module for invoicing (3.12)
python-trytond-account:v12 Tryton module for accounting (3.12)
python-trytond-company:v12 Tryton module with companies and employees (3.12)
python-trytond-country:v12 Tryton module with countries (3.12)
python-trytond-currency:v12 Tryton module with currencies (3.12)
python-trytond-party:v12 Tryton module with parties and addresses (3.12)
python-trytond-product:v12 Tryton module with products (3.12)
python-trytond-purchase:v12 Tryton module for purchase (3.12)
python-trytond-stock:v12 Tryton module for stock and inventory (3.12)
python-trytond:v12 Tryton server (3.12)