# \#python-sql

**URL:** https://discuss.tryton.org/tag/python-sql/13.md

[Latest](https://discuss.tryton.org/latest.md) · [Categories](https://discuss.tryton.org/categories.md) · [Tags](https://discuss.tryton.org/tags.md)

---

## [Release 1.7.0 of python-sql](https://discuss.tryton.org/t/release-1-7-0-of-python-sql/9157)

<div class="topic-metadata">

**Author:** [@ced](https://discuss.tryton.org/u/ced)\
**Replies:** 0\
**Last updated:** [March 22, 2026, 9:18am UTC](https://discuss.tryton.org/t/release-1-7-0-of-python-sql/9157 "2026-03-22T09:18:06Z")

</div>

We are proud to announce the release of the version 1.7.0 of python-sql. python-sql is a library to write SQL queries in a pythonic way. It is mainly developed for Tryton but it has no external dependencies and is agnos…

---

## [Alias Error when i use a sql.table class](https://discuss.tryton.org/t/alias-error-when-i-use-a-sql-table-class/8697)

<div class="topic-metadata">

**Author:** [@manuelze](https://discuss.tryton.org/u/manuelze)\
**Replies:** 4\
**Last updated:** [June 27, 2025, 12:18pm UTC](https://discuss.tryton.org/t/alias-error-when-i-use-a-sql-table-class/8697 "2025-06-27T12:18:52Z")

</div>

Bonjour à tous.. J’ai une erreur lorsque j’utilise les alias lors des requêtes sql au niveau de table\_query. Voici mon code détaillée : @classmethod def table\_query(cls): SalePriceList = Pool().get('produ…

---

## [Release 1.6.0 of python-sql](https://discuss.tryton.org/t/release-1-6-0-of-python-sql/8550)

<div class="topic-metadata">

**Author:** [@ced](https://discuss.tryton.org/u/ced)\
**Replies:** 0\
**Last updated:** [May 2, 2025, 8:01pm UTC](https://discuss.tryton.org/t/release-1-6-0-of-python-sql/8550 "2025-05-02T20:01:51Z")

</div>

We are proud to announce the release of the version 1.6.0 of python-sql. python-sql is a library to write SQL queries in a pythonic way. It is mainly developed for Tryton but it has no external dependencies and is agnos…

---

## [Is this a bug in python-sql?](https://discuss.tryton.org/t/is-this-a-bug-in-python-sql/8546)

<div class="topic-metadata">

**Author:** [@bell](https://discuss.tryton.org/u/bell)\
**Replies:** 3\
**Last updated:** [May 1, 2025, 5:11pm UTC](https://discuss.tryton.org/t/is-this-a-bug-in-python-sql/8546 "2025-05-01T17:11:56Z")

</div>

Hi! I noticed that my sql-query is not being executed correctly. I have modeled a simple example: user = Table('res\_user') group = user.create\_uid total = Sum(Case((user.write\_uid == 2, 3), else\_=4)) …

---

## [Security Release for issue #93](https://discuss.tryton.org/t/security-release-for-issue-93/7889)

<div class="topic-metadata">

**Author:** [@ced](https://discuss.tryton.org/u/ced)\
**Replies:** 1\
**Last updated:** [October 10, 2024, 2:19pm UTC](https://discuss.tryton.org/t/security-release-for-issue-93/7889 "2024-10-10T14:19:02Z")

</div>

Cédric Krier has found that python-sql does not escape non-Expression for unary operators (like And and Or) which makes any system exposing those vulnerable to an SQL injection attack. Impact CVSS v3.0 Base Score: 9.1 …

---

## [Support json in query](https://discuss.tryton.org/t/support-json-in-query/7525)

<div class="topic-metadata">

**Author:** [@tiyujopite](https://discuss.tryton.org/u/tiyujopite)\
**Replies:** 2\
**Last updated:** [August 7, 2024, 8:01am UTC](https://discuss.tryton.org/t/support-json-in-query/7525 "2024-08-07T08:01:47Z")

</div>

Hi, I would like to know if python-sql has support for this type of queries. And if yes, how is the syntax? Thanks in advance. SELECT id FROM table WHERE data::json -\>\> 'key' = 'my\_key'

---

## [Security Release for issue #92](https://discuss.tryton.org/t/security-release-for-issue-92/7330)

<div class="topic-metadata">

**Author:** [@nicoe](https://discuss.tryton.org/u/nicoe)\
**Replies:** 0\
**Last updated:** [June 10, 2024, 8:00am UTC](https://discuss.tryton.org/t/security-release-for-issue-92/7330 "2024-06-10T08:00:14Z")

</div>

Ashish Kunwar has found that python-sql accepts any string in the offset or limit parameters when python is ran with -O which makes any system exposing those vulnerable to an SQL injection attack. Impact CVSS v3.0 Base …

---

## [Is there a way to "select from select" in table\_query?](https://discuss.tryton.org/t/is-there-a-way-to-select-from-select-in-table-query/7292)

<div class="topic-metadata">

**Author:** [@lb1975](https://discuss.tryton.org/u/lb1975)\
**Replies:** 4\
**Last updated:** [May 29, 2024, 7:41am UTC](https://discuss.tryton.org/t/is-there-a-way-to-select-from-select-in-table-query/7292 "2024-05-29T07:41:41Z")

</div>

Hi, I’m wondering if it’s possible by code to replicate the SQL syntax in table\_query def: “select tt.id from (select id as id from table t) tt” and where I can find an example ? Tks in advance, Laurent

---

## [Release 1.5.0 of python-sql](https://discuss.tryton.org/t/release-1-5-0-of-python-sql/7278)

<div class="topic-metadata">

**Author:** [@ced](https://discuss.tryton.org/u/ced)\
**Replies:** 1\
**Last updated:** [May 14, 2024, 8:33am UTC](https://discuss.tryton.org/t/release-1-5-0-of-python-sql/7278 "2024-05-14T08:33:12Z")

</div>

We are proud to announce the release of the version 1.5.0 of python-sql. python-sql is a library to write SQL queries in a pythonic way. It is mainly developed for Tryton but it has no external dependencies and is agnos…

---

## [Very slow SQL query](https://discuss.tryton.org/t/very-slow-sql-query/7256)

<div class="topic-metadata">

**Author:** [@bell](https://discuss.tryton.org/u/bell)\
**Replies:** 7\
**Last updated:** [May 3, 2024, 12:33pm UTC](https://discuss.tryton.org/t/very-slow-sql-query/7256 "2024-05-03T12:33:17Z")

</div>

Hi, I need to execute SQL query like this: main.join(add1, 'LEFT', condition=main.add1\_id == add1.id ).join(add2, 'LEFT', condition=main.add2\_id == add2.id ... ).join(par1, 'LEFT', condition…

---

## [Performance issue computing query params](https://discuss.tryton.org/t/performance-issue-computing-query-params/7223)

<div class="topic-metadata">

**Author:** [@sergyo](https://discuss.tryton.org/u/sergyo)\
**Replies:** 10\
**Last updated:** [April 23, 2024, 5:51pm UTC](https://discuss.tryton.org/t/performance-issue-computing-query-params/7223 "2024-04-23T17:51:46Z")

</div>

I have a complex python-sql query with subqueries, joins, coalesce, case, round, groupby, etc. A lot of python-sql classes which uses params. All this become in ~250 query params. When I try to evaluate query.params it …

---

## [Interval in python-sql query](https://discuss.tryton.org/t/interval-in-python-sql-query/7180)

<div class="topic-metadata">

**Author:** [@miguel](https://discuss.tryton.org/u/miguel)\
**Replies:** 1\
**Last updated:** [April 14, 2024, 7:59am UTC](https://discuss.tryton.org/t/interval-in-python-sql-query/7180 "2024-04-14T07:59:51Z")

</div>

Hello: Using the python-sql library, is it possible to write a query that contains the ‘interval’ operator, for example a query like the following where ‘date\_time\_att’ is of type DateTime?: select date\_time\_att - inte…

---

## [How to write SQL clause were group of columns is in array of values](https://discuss.tryton.org/t/how-to-write-sql-clause-were-group-of-columns-is-in-array-of-values/6345)

<div class="topic-metadata">

**Author:** [@andres53016](https://discuss.tryton.org/u/andres53016)\
**Replies:** 2\
**Last updated:** [July 14, 2023, 5:07pm UTC](https://discuss.tryton.org/t/how-to-write-sql-clause-were-group-of-columns-is-in-array-of-values/6345 "2023-07-14T17:07:57Z")

</div>

I want create a SQL query like this: select \* from table where (table.id,table.state) in (values (80,'stateA'),(13,'stateB')) But I don’t know how to group the columns to call the in\_ method. Thanks in advance.

---

## [Upgrade to python-sql 1.4.1 breaks tryton-worker in Trytond 5.0.38](https://discuss.tryton.org/t/upgrade-to-python-sql-1-4-1-breaks-tryton-worker-in-trytond-5-0-38/6275)

<div class="topic-metadata">

**Author:** [@jonl](https://discuss.tryton.org/u/jonl)\
**Replies:** 3\
**Last updated:** [June 19, 2023, 2:04pm UTC](https://discuss.tryton.org/t/upgrade-to-python-sql-1-4-1-breaks-tryton-worker-in-trytond-5-0-38/6275 "2023-06-19T14:04:38Z")

</div>

The upgrade of python-sql from 1.4.0 to 1.4.1 causes the trytond-worker command to fail with the error: Traceback (most recent call last): File "/usr/local/bin/trytond-worker", line 26, in \<module\> worker.work(opt…

---

## [Feature python-sql agregate ArrayAgg](https://discuss.tryton.org/t/feature-python-sql-agregate-arrayagg/5580)

<div class="topic-metadata">

**Author:** [@wgs](https://discuss.tryton.org/u/wgs)\
**Replies:** 1\
**Last updated:** [October 4, 2022, 4:12pm UTC](https://discuss.tryton.org/t/feature-python-sql-agregate-arrayagg/5580 "2022-10-04T16:12:55Z")

</div>

Proposal This allows to create a query of many records already grouped into a list which can be used immediately. Implementation: class ArrayAgg(Aggregate): \_\_slots\_\_ = () \_sql = 'ARRAY\_AGG'

---

## [Pymssql and python-sql error: alias not allowed in update insert query](https://discuss.tryton.org/t/pymssql-and-python-sql-error-alias-not-allowed-in-update-insert-query/5534)

<div class="topic-metadata">

**Author:** [@mboscolo](https://discuss.tryton.org/u/mboscolo)\
**Replies:** 4\
**Last updated:** [September 15, 2022, 11:54am UTC](https://discuss.tryton.org/t/pymssql-and-python-sql-error-alias-not-allowed-in-update-insert-query/5534 "2022-09-15T11:54:29Z")

</div>

Using the module python-sql with pymssql give an error in case of insert or update query. there is any way to disable alias for for update and insert ? Thanks in advance Matteo

---

## [Support for FTS and MATCH statements?](https://discuss.tryton.org/t/support-for-fts-and-match-statements/5474)

<div class="topic-metadata">

**Author:** [@goruneta](https://discuss.tryton.org/u/goruneta)\
**Replies:** 1\
**Last updated:** [August 16, 2022, 11:58am UTC](https://discuss.tryton.org/t/support-for-fts-and-match-statements/5474 "2022-08-16T11:58:11Z")

</div>

Does python-sql have (or the possibility to have) functions/classes for statements unique to FTS (in SQLite)? Such as: SELECT \* FROM TableFTS WHERE TableFTS MATCH '...'

---

## [A way to add to where clauses without brackets?](https://discuss.tryton.org/t/a-way-to-add-to-where-clauses-without-brackets/5471)

<div class="topic-metadata">

**Author:** [@goruneta](https://discuss.tryton.org/u/goruneta)\
**Replies:** 1\
**Last updated:** [August 14, 2022, 11:17am UTC](https://discuss.tryton.org/t/a-way-to-add-to-where-clauses-without-brackets/5471 "2022-08-14T11:17:18Z")

</div>

When I add operations to a select’s where, the prior existing value is grouped together with brackets: \>\>\> import sql, sql.operators \>\>\> table = sql.Table("Test") \>\>\> select = table.select(table.a) \>\>\> select.where = sq…

---

## [How to not use aliases for tables?](https://discuss.tryton.org/t/how-to-not-use-aliases-for-tables/5468)

<div class="topic-metadata">

**Author:** [@goruneta](https://discuss.tryton.org/u/goruneta)\
**Replies:** 6\
**Last updated:** [August 12, 2022, 9:55am UTC](https://discuss.tryton.org/t/how-to-not-use-aliases-for-tables/5468 "2022-08-12T09:55:48Z")

</div>

The 'a', 'b', … aliases are pretty un-intuitive, is there a way to not use aliases and use the table names instead?

---

## [Any way to SELECT GROUP\_CONCAT(DISTINCT column)?](https://discuss.tryton.org/t/any-way-to-select-group-concat-distinct-column/5465)

<div class="topic-metadata">

**Author:** [@goruneta](https://discuss.tryton.org/u/goruneta)\
**Replies:** 4\
**Last updated:** [August 11, 2022, 4:09pm UTC](https://discuss.tryton.org/t/any-way-to-select-group-concat-distinct-column/5465 "2022-08-11T16:09:42Z")

</div>

Is there a way to use GROUP\_CONCAT() function in the SELECT statement? Was looking for something like from sql import Table t = Table("t") t.select(functions.GroupConcat(t.column, distinct=True)) but can’t seem to fin…

---

## [Scalar subquery in limit clause](https://discuss.tryton.org/t/scalar-subquery-in-limit-clause/5328)

<div class="topic-metadata">

**Author:** [@bell](https://discuss.tryton.org/u/bell)\
**Replies:** 4\
**Last updated:** [June 6, 2022, 11:19am UTC](https://discuss.tryton.org/t/scalar-subquery-in-limit-clause/5328 "2022-06-06T11:19:48Z")

</div>

I need to run a query like this: table1.select(limit=(table2.select(Count(table2.id)))) When I do this I get AssertionError message. Is it possible to use a scalar subquery in limit clause?

---

## [Previous table column value in update query](https://discuss.tryton.org/t/previous-table-column-value-in-update-query/5313)

<div class="topic-metadata">

**Author:** [@bell](https://discuss.tryton.org/u/bell)\
**Replies:** 7\
**Last updated:** [June 2, 2022, 2:30pm UTC](https://discuss.tryton.org/t/previous-table-column-value-in-update-query/5313 "2022-06-02T14:30:46Z")

</div>

I need to run a query like this: t.update(\[t.code\], \[t.code + 1\]) In response, I receive a message: psycopg2.errors.SyntaxError: syntax error at or near "%" UPDATE "t" AS "a" SET "code" = ("a"."code" + %s)

---

## [Quotes in generated code](https://discuss.tryton.org/t/quotes-in-generated-code/4845)

<div class="topic-metadata">

**Author:** [@JohnC](https://discuss.tryton.org/u/JohnC)\
**Replies:** 2\
**Last updated:** [December 10, 2021, 1:07pm UTC](https://discuss.tryton.org/t/quotes-in-generated-code/4845 "2021-12-10T13:07:48Z")

</div>

Hi I’m trying to us python-sql with mysql and I really want it to work as SQL seems like something out of the COBAL era. Here is some example code and the generated output #! python3.8 import mysql.connector as mysql i…

---

## [Release 1.3.0 of python-sql](https://discuss.tryton.org/t/release-1-3-0-of-python-sql/4618)

<div class="topic-metadata">

**Author:** [@ced](https://discuss.tryton.org/u/ced)\
**Replies:** 0\
**Last updated:** [September 14, 2021, 8:08am UTC](https://discuss.tryton.org/t/release-1-3-0-of-python-sql/4618 "2021-09-14T08:08:55Z")

</div>

We are proud to announce the release of the version 1.3.0 of python-sql. python-sql is a library to write SQL queries in a pythonic way. It is mainly developed for Tryton but it has no external dependencies and is agnos…

---

## [Python-sql In some cases this results in hundreds of thousands of calls to the \_\_str\_\_ loop](https://discuss.tryton.org/t/python-sql-in-some-cases-this-results-in-hundreds-of-thousands-of-calls-to-the-str-loop/4169)

<div class="topic-metadata">

**Author:** [@zhuo.wang](https://discuss.tryton.org/u/zhuo.wang)\
**Replies:** 3\
**Last updated:** [May 9, 2021, 9:32am UTC](https://discuss.tryton.org/t/python-sql-in-some-cases-this-results-in-hundreds-of-thousands-of-calls-to-the-str-loop/4169 "2021-05-09T09:32:44Z")

</div>

Hai, I’m using python-sql in python2.7 windows now，In some cases, parsing SQL is getting slow. I generated pickle objects from SQL objects, and I noticed that the str method parsing SQL seems to be called in a loop. An …

---

## [Basic Tutorial for python-sql](https://discuss.tryton.org/t/basic-tutorial-for-python-sql/3999)

<div class="topic-metadata">

**Author:** [@suvo](https://discuss.tryton.org/u/suvo)\
**Replies:** 5\
**Last updated:** [April 4, 2021, 11:48am UTC](https://discuss.tryton.org/t/basic-tutorial-for-python-sql/3999 "2021-04-04T11:48:42Z")

</div>

I am startng python-sql today. Where are the basic guides which I ca use? Looking for fool-proof tutorial with example and output

---

## [Action window errors on python-sql \> 1.2.0](https://discuss.tryton.org/t/action-window-errors-on-python-sql-1-2-0/3329)

<div class="topic-metadata">

**Author:** [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Replies:** 5\
**Last updated:** [October 7, 2020, 8:36pm UTC](https://discuss.tryton.org/t/action-window-errors-on-python-sql-1-2-0/3329 "2020-10-07T20:36:12Z")

</div>

Since the recent relase of python-sql I’ve seen two of our tryton tests suites failing with the following exception: ERROR: test\_ir\_action\_window (tests.test\_xxxx.xxxxTestCase) Test action windows are correctly defined …

---

## [Release 1.2.0 of python-sql](https://discuss.tryton.org/t/release-1-2-0-of-python-sql/3324)

<div class="topic-metadata">

**Author:** [@ced](https://discuss.tryton.org/u/ced)\
**Replies:** 0\
**Last updated:** [October 5, 2020, 4:43pm UTC](https://discuss.tryton.org/t/release-1-2-0-of-python-sql/3324 "2020-10-05T16:43:08Z")

</div>

We are proud to announce the release of the version 1.2.0 of python-sql. python-sql is a library to write SQL queries in a pythonic way. It is mainly developed for Tryton but it has no external dependencies and is agnos…

---

## [Complex WHERE clauses in python-sql, length](https://discuss.tryton.org/t/complex-where-clauses-in-python-sql-length/2664)

<div class="topic-metadata">

**Author:** [@Artanicus](https://discuss.tryton.org/u/Artanicus)\
**Replies:** 2\
**Last updated:** [April 30, 2020, 9:01pm UTC](https://discuss.tryton.org/t/complex-where-clauses-in-python-sql-length/2664 "2020-04-30T21:01:07Z")

</div>

I’m attempting a WHERE clause checking the length of a column value. len however hasn’t been implemented at least in a way I can find intuitively. gym = Table('qym') se…

---

## [Union of multiple SQL queries](https://discuss.tryton.org/t/union-of-multiple-sql-queries/2299)

<div class="topic-metadata">

**Author:** [@bell](https://discuss.tryton.org/u/bell)\
**Replies:** 2\
**Last updated:** [February 7, 2020, 12:17pm UTC](https://discuss.tryton.org/t/union-of-multiple-sql-queries/2299 "2020-02-07T12:17:33Z")

</div>

Suppose we have a union of three queries: union = query1 | query2 | query3 union.all\_ = True Why does the ALL key only apply to the union of query2 and query3? We need the ALL key to be applied to all union operations…

[Next page](https://discuss.tryton.org/tag/python-sql/13.md?match_all_tags=true&page=1&tags%5B%5D=python-sql)
