Re: [python-sql] how where clause is parsed

2019-03-20 Thread 'Cédric Krier' via python-sql
. This is simply done by override the standard operators of Python in the Expression class (which derive all SQL expressions) -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message because you are su

Re: [python-sql] select items from a list

2019-03-20 Thread 'Cédric Krier' via python-sql
a risk that the attribute name collide with an attribute of the class. So the best option is to instantiate columns: columns = [Column(table1, f) for f in ["field1", "field2"]] query = table1.select(columns) -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck

Re: [python-sql] arbitrary strings and ints in where

2019-03-18 Thread 'Cédric Krier' via python-sql
; WHERE 1 = 1 > > Is this something that's possible? Yes, you must use explicit Literal: select.where = Literal(1) == Literal(1) -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message

Re: [python-sql] a newbie use

2019-01-08 Thread 'Cédric Krier' via python-sql
.execute(*select) The query object is iterable and return the query string follwed by the params. Or if you prefer you can also run: cursor.execute(str(select), select.params) -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.co

Re: [python-sql] arrays and json with python-sql

2017-09-07 Thread Cédric Krier
Aggregate class ArrayAgg(Aggregate): __slots__ = () _sql = 'ARRAY_AGG' ARRAY_TO_JSON is even less in the standard as JSON type is not in the standard. But it can also easily implemented: from sql.functions import Function class ArrayToJson(Function):

Re: [python-sql] Re: how to alias target table of multiple inner joins

2017-09-07 Thread Cédric Krier
On 2017-09-07 17:08, Richard PALO wrote: > Do I understand therefore that aliasing is indeed not supported on tables > (that is, only on columns)? alias on table is pointless in python-sql because query is written using Python variable which has the same purpose. -- Cédric Krier - B2C

Re: [python-sql] WHERE clause with multiple AND statements

2017-09-06 Thread Cédric Krier
question about optimizing the __and__ operator to append to the first And instead of encapsulate. I think it is an optimization that will increase code complexity for a very small gain (2 chars). -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://

Re: [python-sql] Re: how to alias target table of multiple inner joins

2017-09-06 Thread Cédric Krier
code, jnl.name, jnl.type, jnl.sequence_name, > > jnl.default_debit_account, jnl.default_credit_account) > > > > > > The print statement pretty much shows the query I intended though what I don't > get now is why python-sql needs the 'distinct_on' cla

[python-sql] Release 0.9

2017-04-24 Thread Cédric Krier
://pypi.python.org/pypi/python-sql/0.9 -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message because you are subscribed to the Google Groups "python-sql" group. To unsubscribe from this group and stop receiv

Re: [python-sql] SELECT DISTINCT

2016-09-21 Thread Cédric Krier
op-post on this mailing list, see http://groups.tryton.org/netiquette -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message because you are subscribed to the Google Groups "python-sql" group. T

Re: [python-sql] SELECT DISTINCT

2016-09-14 Thread Cédric Krier
On 2016-09-14 10:35, Cédric Krier wrote: > On 2016-09-14 00:10, Ruben Nielsen wrote: > > Any plans on adding SELECT DISTINCT? I see in the code, that there is a > > TODO comment in place. > > Usually DISTINCT can be avoided by using a GROUP BY. > But it should not be to

Re: [python-sql] SELECT DISTINCT

2016-09-14 Thread Cédric Krier
is was not planned to support Select replacement. Indeed what do you try to add? -- Cédric Krier - B2CK SPRL Email/Jabber: cedric.kr...@b2ck.com Tel: +32 472 54 46 59 Website: http://www.b2ck.com/ -- You received this message because you are subscribed to the Google Groups "python-sql&quo