[sqlalchemy] Re: Trying to find a way to sort a query given the name of one of its columns

2023-06-12 Thread Lele Gaifax
Lele Gaifax writes: > I will study the contains_eager() alternative and try to modernize my > code that still uses that idiom. After reading the different sections (narrative and reference), I wonder if there is a case where the joinedload() has some advantage over contains

[sqlalchemy] Re: Trying to find a way to sort a query given the name of one of its columns

2023-06-12 Thread Lele Gaifax
erred to share code snippets) Sorry, note taken. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLAlchemy - The Pytho

[sqlalchemy] Re: Trying to find a way to sort a query given the name of one of its columns

2023-06-10 Thread Lele Gaifax
der_by() normally, then > use contains_eager(). Oh, thanks a lot for this!. Accordingly with the git history, I introduced that test to address a deprecation warning issued by SA 1.4+ load_only()... I will study the contains_eager() alternative and try to modernize my code that still uses th

[sqlalchemy] Trying to find a way to sort a query given the name of one of its columns

2023-06-10 Thread Lele Gaifax
firstname', String(), table=) Can you shed some light on what I can try to smooth this different behaviour? Thanks a lot in advance, bye, lele. [1] https://gitlab.com/metapensiero/metapensiero.sqlalchemy.proxy [2] https://gitlab.com/metapensiero/metapensiero.sqlalchemy.proxy/-/blob/8

[sqlalchemy] Re: Dealing with readonly column

2023-04-14 Thread Lele Gaifax
"Mike Bayer" writes: > On Fri, Apr 14, 2023, at 8:03 AM, Lele Gaifax wrote: >> I now have >> >> CREATE TABLE something (id SERIAL, name TEXT) >> >> CREATE FUNCTION counter(something) >> RETURNS INTEGER AS $$ >> SELECT count(*) FROM

[sqlalchemy] Dealing with readonly column

2023-04-14 Thread Lele Gaifax
he value [assigned to the column] will be ignored", so that does not bring me any advantage. On the ORM side, I could "hide" the concrete column and expose it thru a readonly property, but I'd like to have a similar safety-belt also at the Core layer, because many services/APIs w

[sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Lele Gaifax
q.limit(3).all()]) and emits [('2° Torneo', datetime.date(2001, 4, 1)), ('7° Torneo', datetime.date(2004, 4, 24)), ('7° Torneo', datetime.date(2005, 4, 30))] Hope this helps, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincer

[sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Lele Gaifax
unc.strftime('%m', func.date(Events.date_of_event) == > datetime.today().strftime('%m')) You are passing a boolean value to the strftime() function, and that's not what you probably meant/want. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gai

[sqlalchemy] Re: ext.hybrid.Comparator.property not implemented in SA2

2023-02-16 Thread Lele Gaifax
"Mike Bayer" writes: > On Thu, Feb 16, 2023, at 7:16 AM, Lele Gaifax wrote: >> >> TL;DR >> >> Why is the sqlalchemy.ext.hybrid.Comparator.property explicitly >> raising a NotImplementedError? > > the .property attribute in the base PropCom

[sqlalchemy] ext.hybrid.Comparator.property not implemented in SA2

2023-02-16 Thread Lele Gaifax
etermine whether it should assign a scalar value or an instance to the target. In SA 2, the ext.hybrid.Comparator explicitly[6] defines the "property" property as "not defined" (sorry for the pun), and I could not figure out the rationale. While I keep digging and trying, ma

[sqlalchemy] Re: Alembic and SA 2: upgrade ends with a rollback

2023-01-15 Thread Lele Gaifax
equirements/base.txt). I'm testing against a copy of the production DB, but it actually does not make any difference, as the same happens with an empty development db. Thanks, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò a

[sqlalchemy] Re: Alembic and SA 2: upgrade ends with a rollback

2023-01-15 Thread Lele Gaifax
"Mike Bayer" writes: > There's a few things going on here, and I can see the code here in > your "master" branch at least hasn't been updated for 2.0. See https://gitlab.com/metapensiero/SoL/-/commits/sol5 bye, lele. -- nickname: Lele Gaifax | Quando vivrò di quell

[sqlalchemy] Re: Alembic and SA 2: upgrade ends with a rollback

2023-01-15 Thread Lele Gaifax
ing current state and pushing it right now. > Will be back on your other remarks later. Thanks, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortuna

[sqlalchemy] Re: Alembic and SA 2: upgrade ends with a rollback

2023-01-15 Thread Lele Gaifax
gine.Engine: [raw sql] () 16:56:36 [I] sqlalchemy.engine.Engine: ROLLBACK Traceback (most recent call last): File "/home/lele/wip/sol5/env/bin/soladmin", line 33, in sys.exit(load_entry_point('SoL', 'console_scripts', 'soladmin')()) ^

[sqlalchemy] Alembic with SQLite FOREIGN_KEYS pragma

2023-01-15 Thread Lele Gaifax
figure( connection=connection, target_metadata=target_metadata ) with context.begin_transaction(): context.run_migrations() As this unconditionally affects all migrations, it obviously may ruins further ones, where the FK check would be desiderable. Can you suggest some

[sqlalchemy] Alembic and SA 2: upgrade ends with a rollback

2023-01-15 Thread Lele Gaifax
lembic in this project (ten years, omg!), but even modernizing it using Alembic 1.9.2 template didn't help: when the connection is closed, either explicitly by the old try:finally: code or implicitly by the new connectable.connect() context manager, a ROLLBACK is issued. Do you have an hint

[sqlalchemy] Re: Where is the exactly .db file if I use sqlite code in the example

2022-12-06 Thread Lele Gaifax
tps://docs.sqlalchemy.org/en/14/dialects/sqlite.html#connect-strings, that syntax is equivalent to sqlite://:memory:, and thus there is no file involved. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi

[sqlalchemy] Re: Reflections on the SA 2.0 new PG Range

2022-12-04 Thread Lele Gaifax
"Mike Bayer" writes: > there should definitely be an "isempty" accessor, but from SQLA's > naming conventions we prefer to have "is_empty" as the official name. > There's a bunch of precedent for this. overall people should be able > to use either

[sqlalchemy] Re: Reflections on the SA 2.0 new PG Range

2022-12-04 Thread Lele Gaifax
py: is_false(bool(Range(empty=True))) test/dialect/postgresql/test_types.py:eq_(data, [(self._data_obj().__class__(empty=True),)]) test/dialect/postgresql/test_types.py:eq_(data, [(self._data_obj().__class__(empty=True),)]) thanks, lele. -- nickname: Lele Gaifax | Quand

[sqlalchemy] Re: Reflections on the SA 2.0 new PG Range

2022-12-01 Thread Lele Gaifax
"Mike Bayer" writes: > On Thu, Dec 1, 2022, at 1:01 PM, Lele Gaifax wrote: >> Wrt "empty", what's your preference, leaving it as is and expose a >> "isempty" property or rename the attribute to "isempty" (and possibly) >&g

[sqlalchemy] Re: Reflections on the SA 2.0 new PG Range

2022-12-01 Thread Lele Gaifax
"Mike Bayer" writes: > On Wed, Nov 30, 2022, at 2:31 PM, Lele Gaifax wrote: >> "Mike Bayer" writes: >> >> > On Wed, Nov 30, 2022, at 10:30 AM, Lele Gaifax wrote: >> >> >> >> - "empty" vs "isempty": both

[sqlalchemy] Re: Reflections on the SA 2.0 new PG Range

2022-11-30 Thread Lele Gaifax
"Mike Bayer" writes: > On Wed, Nov 30, 2022, at 10:30 AM, Lele Gaifax wrote: >> On the former one, it would be nice if we could reduce the "distance" >> between the new Range class and what popular drivers provide: >> >> - "empty&quo

[sqlalchemy] Reflections on the SA 2.0 new PG Range

2022-11-30 Thread Lele Gaifax
ecent improvements to the Range class, to be able to determine a "discrete step" for each of them. So I wonder if it would be reasonable/doable/affordable if SA could grow a "family" of classes, derived from current Range, one for each data type, so that for example a D

[sqlalchemy] Learning to use new PG Ranges

2022-11-26 Thread Lele Gaifax
direct cause of the following exception: Traceback (most recent call last): File "/home/lele/wip/etour/ndn/hopi/next/tmp/sa_range_contains/test.py", line 49, in tusage = session.execute( File "/nix/.../sqlalchemy/orm/session.py", line 2081, in execute

[sqlalchemy] Re: sqlacodegen getting error

2022-11-13 Thread Lele Gaifax
e-orm.com/en/latest/peewee/playhouse.html#pwiz for Peewee. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLAlchemy

[sqlalchemy] Re: sqlacodegen getting error

2022-11-13 Thread Lele Gaifax
cation period in https://github.com/python/cpython/pull/28618, replaced by FullArgSpec. Reasonably this should be reported to sqlacodegen team. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di

[sqlalchemy] Re: On new native PG Range in SA 2.0

2022-10-24 Thread Lele Gaifax
m the connection.dialect. But hey, I do not expected those arguments will be changing often... :-) ciao, lele -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortun

[sqlalchemy] Re: On new native PG Range in SA 2.0

2022-10-24 Thread Lele Gaifax
manually coded those values. For that reason I didn't (yet) created an issue and proposed a PR. Mike, can you tell me if this is acceptable or how can I improve it? Thanks, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di

[sqlalchemy] Re: On new native PG Range in SA 2.0

2022-10-23 Thread Lele Gaifax
Lele Gaifax writes: > I will propose a PR soon. An ethical concern: given that the proposed methods are so simple, is it legal/acceptable to verbatim copy them, and their tests, from the psycopg (LGPL) and asyncpg (Apache license)? ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di que

[sqlalchemy] Re: On new native PG Range in SA 2.0

2022-10-23 Thread Lele Gaifax
directly. I would just disagree with > psycopg2's more nonsensical methods like `__lt__`, `__gt__`, etc. > Thank you for the directions: while I'm not 100% convinced about avoiding __contains__(), which seems very intuitive and practical, I will propose a PR soon. ciao, lele. -- nickname: Lele

[sqlalchemy] On new native PG Range in SA 2.0

2022-10-22 Thread Lele Gaifax
return self.active and date.today() in self.validity to something different, that in some way "reaches" the underlying psycopg (say) implementation and uses its logic? Thanks in advance, ciao, lele. -- nickname: Lele Gaifax | Dire che Emacs è "conveniente" è come rea

[sqlalchemy] Re: Problem with PG ARRAY's ANY() and SA 1.4.36 (maybe related resolution of #6515 ?)

2022-05-03 Thread Lele Gaifax
"chunks" generated by common functions, used in several other places. It would be very impractical to carry around the whole set of "parameters" and use the implicit/automatic injection made by SA. Thanks again, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho p

[sqlalchemy] Problem with PG ARRAY's ANY() and SA 1.4.36 (maybe related resolution of #6515 ?)

2022-04-29 Thread Lele Gaifax
uld do... but given that the above idiom has worked well for me for so long, this may very well be an unintended side effect of https://github.com/sqlalchemy/sqlalchemy/commit/63191fbef63ebfbf57e7b66bd6529305fc62c605. Thank you for any hint, ciao, lele. -- nickname: Lele Gaifax | Dire che Ema

[sqlalchemy] Re: update with in clause from kwargs

2021-08-05 Thread Lele Gaifax
on. I think a full traceback could help in diagnosing the problem. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLAlchemy -

[sqlalchemy] Re: update with in clause from kwargs

2021-08-04 Thread Lele Gaifax
lter_group` with something like attr = getattr(self.model_class, col) filter_group.append(attr.in_(tuple(kwargs['query_params'][col]))) that is, obtain the mapped class member named after "col", and use that to build the filter expression. ciao, lele. -- nickname: Lele Gaifax | Qua

[sqlalchemy] Re: Relationship backref cascade path

2021-07-24 Thread Lele Gaifax
"Mike Bayer" writes: > On Sat, Jul 24, 2021, at 5:49 AM, Lele Gaifax wrote: >> Hi all, >> >> I need some clarification on the following RemovedIn20Warning >> >> "Pet" object is being merged into a Session along the backref cascade path &

[sqlalchemy] Relationship backref cascade path

2021-07-24 Thread Lele Gaifax
guring all the "one-to-many" relationships as "viewonly", but that again would require more analysis on the code paths... So, am I missing something and there is some recommended alternative, or should I dig into the rabbit's hole? Thanks in advance for any hint, ciao, lele. -- SQL

[sqlalchemy] Re: joinedload().load_only() emits 2.0 warning

2021-07-21 Thread Lele Gaifax
Federico Caselli writes: > Updated here https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2959 Great, thank you! ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero

[sqlalchemy] Re: joinedload().load_only() emits 2.0 warning

2021-07-16 Thread Lele Gaifax
Federico Caselli writes: > There is no difference, it's the documentation that's outdated. > > We should update that I see, thank you for the clarification! ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver pau

[sqlalchemy] Re: joinedload().load_only() emits 2.0 warning

2021-07-16 Thread Lele Gaifax
tached to the generic load_only() function documentation uses the string name. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLA

[sqlalchemy] joinedload().load_only() emits 2.0 warning

2021-07-15 Thread Lele Gaifax
the problem. Maybe using joinedload(X.y).load_only(a, b), a and b cannot be column names under 2.0, but should be Y.a and Y.b instead? Thanks a lot for any hint, ciao, lele. [1] https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Load.load_only -- SQLAlchemy - The Python SQL Toolkit

[sqlalchemy] Re: Adapting a library to SA 1.4b1

2020-09-29 Thread Lele Gaifax
"Mike Bayer" writes: > I pushed the fix for that, give it another go. this is good testing you're > doing as you have a lot of SQL Core metaprogramming going on. things are > REALLY different on the inside :) Great, thanks again Mike: this indeed fixed my test

[sqlalchemy] Re: Adapting a library to SA 1.4b1

2020-09-27 Thread Lele Gaifax
"Mike Bayer" writes: > Hi Lele - > > It looks like .froms on a simple select() that is against ORM entities is > just broken here, so > we can fix that. at the moment it's a one liner but there are some > performance implications > that might make it more tri

[sqlalchemy] Adapting a library to SA 1.4b1

2020-09-27 Thread Lele Gaifax
erson.lastname]) .filter(or_(Person.firstname.like('%Lele'), Person.lastname.like('%Lele'))) given an entity, "Person", a string to search and a subset of the columns that shall be considered and extracted. So, this is the test [4]: def test_query(): proxy

[sqlalchemy] Re: Continuing support for Firebird database

2019-11-08 Thread Lele Gaifax
going. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

[sqlalchemy] Re: Usage problem with CTEs and INSERTs

2019-11-05 Thread Lele Gaifax
"Mike Bayer" writes: > On Tue, Nov 5, 2019, at 4:08 AM, Lele Gaifax wrote: >> Hi all, >> >> I'm almost sure I'm missing the obvious, struggling to understand how to use >> a >> CTE with a PG "upsert" statement: I need to modify an exist

[sqlalchemy] Usage problem with CTEs and INSERTs

2019-11-05 Thread Lele Gaifax
nt = (some_sales.amount * %(amount_2)s) == Can anybody shed some light on what I'm doing wrong? Thanks in advance, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it

[sqlalchemy] Re: Finding original "type" when using as_mutable()

2019-07-10 Thread Lele Gaifax
info is one place. sorry there is not a better solution. Thank you Mike, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQL

[sqlalchemy] Finding original "type" when using as_mutable()

2019-07-10 Thread Lele Gaifax
columns, and then check for that, but I wonder if there is an less intrusive way... knowing and loving SA I bet there is and it's just a matter of pronouncing the right incantation :-) Thank you in advance for any hint, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real:

[sqlalchemy] Re: Tiny doc clarification request

2018-11-08 Thread Lele Gaifax
ot; lookup, be it either by string or by integer b) "iterative"/"nested" lookup, one hop at a time over the provided sequence But maybe I'm missing some detail on the "engine specific" implementations, where, say, "foo['string']" may be considered a very diff

[sqlalchemy] Tiny doc clarification request

2018-11-08 Thread Lele Gaifax
as in :: data_table.c.data['some key'] or positional/by integer:: data_table.c.data[3] * Path index operations:: data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')] or is it just a s/two operations/three operations/ ? Thanks, lele. -- nickname: Lele Gaifax | Quando vivrò di

[sqlalchemy] Re: Doubt about server_onupdate=FetchedValue()

2018-02-04 Thread Lele Gaifax
o work at the core layer...), and wasn't sure about it being an error on my configuration. > If these columns have a server side behavior for INSERT then you'd also add > server_default=FetchedValue() and then you wouldn't see the None on INSERT. Thank you, ciao, lele. -- nickname: Lele Gaifax |

[sqlalchemy] Re: KeyError when looping thru class objects to try and copy them

2017-12-20 Thread Lele Gaifax
oop above exits db.session.commit() ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLAlchemy - The Python S

[sqlalchemy] Re: How do I copy an object and save to database?

2017-12-20 Thread Lele Gaifax
Tom Tanner <dontsendemailher...@gmail.com> writes: > Lele, could you write the code showing how that would look? Thanks. Extending Mike's answer: from sqlalchemy.orm import make_transient make_transient(someObj) # someObj is no longer in the session del s

[sqlalchemy] Re: How do I copy an object and save to database?

2017-12-19 Thread Lele Gaifax
) of the cloned object. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLAlchemy - The Python SQL Toolkit and Object R

[sqlalchemy] Re: About CASTing query parameters

2017-04-14 Thread Lele Gaifax
mike bayer <mike...@zzzcomputing.com> writes: > yeah IMO this is a bug in asyncpg but of course your custom dialect can work > around that. Ok, thank you. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver pau

[sqlalchemy] Re: About CASTing query parameters

2017-04-14 Thread Lele Gaifax
Lele Gaifax <l...@metapensiero.it> writes: > I bet because it does want to fiddle with the SQL statement parsing, or with > the formatting of parameter's values. ops: ... it does *not* want... ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri re

[sqlalchemy] Re: About CASTing query parameters

2017-04-14 Thread Lele Gaifax
Mike Bayer <clas...@zzzcomputing.com> writes: > Right. So why can't asyncpg do that. I bet because it does want to fiddle with the SQL statement parsing, or with the formatting of parameter's values. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato

[sqlalchemy] Re: About CASTing query parameters

2017-04-14 Thread Lele Gaifax
is SELECT users.id FROM users WHERE users.name = 'myself' AND (users.active @> '2017-04-14'::date) ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- F

[sqlalchemy] Re: About CASTing query parameters

2017-04-14 Thread Lele Gaifax
as not clear that I was suggesting an enhancement, not a fix :-). ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLAlchemy -

[sqlalchemy] Re: About CASTing query parameters

2017-04-14 Thread Lele Gaifax
m(): Yes, I know, but since I need to tweak the representation of positional parameters (that is, $1 instead of :1), I had to touch the BIND_TEMPLATES content. That's why I thought a more generic approach of allowing an arbitrary, user controlled way to render the placeholders could be better. ciao,

[sqlalchemy] About CASTing query parameters

2017-04-14 Thread Lele Gaifax
rs.validity @> $2::DATE) Since it eventually boils down to overriding a single "private" method (_apply_numbered_params), I wonder if it would be a welcome addition to standard SA, maybe allowing to set "paramstyle" to an user's arbitrary callable. What do you think? Thank you

[sqlalchemy] Re: Problems with sqlalchemy and timestamps

2017-03-07 Thread Lele Gaifax
does not reference the correct column but the whole table. Also, I'd try to find a better way to pass the parameter, possibly without transforming it into a string with isoformat(). ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad

[sqlalchemy] Re: Using psql commands (i.e. \d) through sqlalchemy.core

2016-10-31 Thread Lele Gaifax
pi/pgspecial, used for example by pgcli, a Python-based alternative to psql. ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- SQLAlchemy

[sqlalchemy] Re: Handling "generic" relations

2016-10-21 Thread Lele Gaifax
Simon King <si...@simonking.org.uk> writes: > There are a few examples of different ways of doing this at > http://docs.sqlalchemy.org/en/latest/orm/examples.html#module-examples.generic_associations. Excellent, thank you for pointing me there! bye, lele. -- nickname: Lele Gai

[sqlalchemy] Handling "generic" relations

2016-10-20 Thread Lele Gaifax
: newaddr = Address(street='somewhere') person.addresses.append(newaddr) so I have to do this instead:: newaddr = Address(street='somewhere', attached_kind='Person', attached_id=person.id) Is there any trick hidden somewhere, or do I need a add_address() method on each entity? Thank you for any hint, ciao,

[sqlalchemy] Re: Assertion error on deleting one end of many-to-many relation

2016-03-03 Thread Lele Gaifax
iation-object > ). Thank you for the link. > You *might* be able to fix this by setting the cascade behaviour on > Person.preferred_activities to "all, delete-orphan": Will try that approach. My current workaround is to explicitly delete the intermediary items before deleting th

[sqlalchemy] Assertion error on deleting one end of many-to-many relation

2016-03-03 Thread Lele Gaifax
out errors person = relationship(Person, backref='preferred_activities') def main(): engine = create_engine('sqlite:///:memory:', echo=True) Session = sessionmaker(bind=engine) sess = Session() Base.metadata.create_all(engine) person = Person(id=1, name='lele') activ

[sqlalchemy] Re: Should RowProxy behave as a standard Python sequence?

2016-01-28 Thread Lele Gaifax
Mike Bayer <mike...@zzzcomputing.com> writes: > reinstate the whole thing in 516a442f233d90eb7b8bb844e2dea7865bb21f66... Ok, see https://github.com/zzzeek/sqlalchemy/pull/231 thank you, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanue

[sqlalchemy] Re: Should RowProxy behave as a standard Python sequence?

2016-01-27 Thread Lele Gaifax
Mike Bayer <mike...@zzzcomputing.com> writes: > On 01/27/2016 05:32 AM, Lele Gaifax wrote: >> Here is the diff implementing the third option: it still need to touch also >> the C implementation, because that does not use the metadata keymap when the >> key is an integer

[sqlalchemy] Re: Should RowProxy behave as a standard Python sequence?

2016-01-27 Thread Lele Gaifax
Lele Gaifax <l...@metapensiero.it> writes: > Let me know how you prefer me going forward: I can easily try out your (now > reverted) change, but it's up to you. The following patch: -- You received this message because you are subscribed to the Google Groups "sqlalchemy"

[sqlalchemy] Re: Should RowProxy behave as a standard Python sequence?

2016-01-27 Thread Lele Gaifax
speedups: $ py.test test/ platform linux -- Python 3.5.1+, pytest-2.8.7, py-1.4.31, pluggy-0.3.1 -- /home/lele/wip/sqlalchemy/env/bin/python3 cachedir: .cache rootdir: /home/lele/wip/sqlalchemy, inifile: setup.cfg collected 7556 items test/aaa_profiling/test_compiler.py::CompileTest_

[sqlalchemy] Re: Should RowProxy behave as a standard Python sequence?

2016-01-25 Thread Lele Gaifax
undant index computation under Py2). Thank you, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- You received this message becaus

[sqlalchemy] Re: Should RowProxy behave as a standard Python sequence?

2016-01-25 Thread Lele Gaifax
ires.cextensions: how can I exercise both implementations (that is, C and pure Python)? Thanks for any feedback, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it |

[sqlalchemy] Re: Should RowProxy behave as a standard Python sequence?

2016-01-24 Thread Lele Gaifax
Mike Bayer <mike...@zzzcomputing.com> writes: > On 01/24/2016 11:11 AM, Lele Gaifax wrote: >> I wonder whether there is an underlying reason or if it's just an oversight. > > both? the rowproxy is addressable by lots of things like strings, > Column objects. if we wa

[sqlalchemy] Should RowProxy behave as a standard Python sequence?

2016-01-24 Thread Lele Gaifax
pure Python version) class or into the ResultMetaData._key_fallback() method? Thank you, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato De

[sqlalchemy] Re: Reflection of table/columns comments

2015-12-16 Thread Lele Gaifax
Mike Bayer <mike...@zzzcomputing.com> writes: > The column_reflect event supports this - you can populate the info > dictionary right there from information that you get out of the > col_description system view. Thank you Mike, as always, you (and consequently SQLAlchemy) shi

[sqlalchemy] Reflection of table/columns comments

2015-12-15 Thread Lele Gaifax
w me to fetch such extra information for each column. It seems that the `Inspector.get_columns()` declares an "attrs" slot, carrying "optional column attributes", but no dialect uses it AFAICT. I could of course tweak/monkey patch the `PGDialect.get_columns()`, but I wond

[sqlalchemy] Dinamically adding an outer join to an existing select

2015-10-24 Thread Lele Gaifax
rjoin(pad, sa.text('true'))) it instead emits the right SQL, that is: SELECT p.id, p.description, p.idkind, pad.price AS price, pad.discount AS discount FROM products AS p LEFT OUTER JOIN price_and_discount(p.id, %(idcustomer)s) AS pad ON true So, is there a "correct way" to dynamicall

[sqlalchemy] Re: There is any chance to SQLAlchemy works with syncio?

2015-09-20 Thread Lele Gaifax
non-blocking > operations too. In the very same context, I'm using a port of the twisted-based Alchimia to asyncio: https://gitlab.com/arstecnica/arstecnica.sqlalchemy.async It only works at the core level of SA, though. hth, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho

[sqlalchemy] A glitch: is it SA's, cymysql's or mine only?

2015-07-20 Thread Lele Gaifax
be catched anyway, either by fixing the driver (cymysql) or SA itself. Thank you, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929

[sqlalchemy] Re: A glitch: is it SA's, cymysql's or mine only?

2015-07-20 Thread Lele Gaifax
never be None if an UPDATE/DELETE were emitted in any case. bug is with cymysql. Ok, I will switch to PyMySQL, if it passes all my current tests. Hopefully I won't loose too much performance and meet other kind of glitches... I'm looking forward to use a better DB! Thank you, bye, lele

[sqlalchemy] Re: Dealing with l10n fields

2015-07-12 Thread Lele Gaifax
(replace_lang(stmt, 'it')) pca = products.alias().c stmt = select([ pca.en.label('description'), pca.en_note.label('summary') ]) print(replace_lang(stmt, 'it')) Is it reasonable, or does the table.original trick fall short in corner cases? Thanks a lot, ciao, lele. -- nickname

[sqlalchemy] Dealing with l10n fields

2015-07-12 Thread Lele Gaifax
to get there, or other approaches I missed? Thanks a lot, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- You received

[sqlalchemy] Re: TypeDecorators and raw inserts

2015-07-01 Thread Lele Gaifax
Mike Bayer mike...@zzzcomputing.com writes: On 6/30/15 6:56 PM, Lele Gaifax wrote: With the approach above custom column types used by the new_table are not playing their magic, and I currently must repeat it within the adapt() function. I assume you mean the data you're getting back from

[sqlalchemy] TypeDecorators and raw inserts

2015-06-30 Thread Lele Gaifax
an insert using its ORM layer, so that I can simplify the adapt() function applying the DRY principle? Thank you in advance for any hints, bye, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l

[sqlalchemy] Re: Mysql issue with big composite primary keys

2014-11-10 Thread Lele Gaifax
is written to permanent storage). hth, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- You received this message because you

[sqlalchemy] Creating a partial unique index on SQLite

2014-09-01 Thread Lele Gaifax
please point me in the right direction? Thanks in advance, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- You received

[sqlalchemy] Re: Creating a partial unique index on SQLite

2014-09-01 Thread Lele Gaifax
statement I used is more like event.listen(MyModel.__table__, after_create, DDL(CREATE UNIQUE INDEX model_c1_vs_c2 ON model (id, idc1, idc2) WHERE flag=0)) ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele

[sqlalchemy] Re: SQLAlchemy 0.9.0 Released

2013-12-31 Thread Lele Gaifax
Michael Bayer mike...@zzzcomputing.com writes: SQLAlchemy release 0.9.0 is now available. Happy new year! Hurrah! Thank you Mike, I'll surely address a Brindisi[1] to you tonight. I used the 0.9 series since its inception basically without a single glitch. You (and SA) rock! ciao, lele. [1

[sqlalchemy] Re: Session() and UnboundLocalError: local variable 'Session' referenced before assignment

2013-08-25 Thread Lele Gaifax
the not recommended idiom of *redefining* a symbol in that way, you should import/define the session maker function from somewhere before you can use it. As said, I'd recommend using different names, to avoid confusion, for example session = SessionMaker() hth, ciao, lele. -- nickname: Lele Gaifax

[sqlalchemy] Re: Selecting across columns with func.min()

2013-08-20 Thread Lele Gaifax
yet to show the proper SA syntax :) hth, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- You received this message because you

[sqlalchemy] Re: views declarative?

2013-04-17 Thread Lele Gaifax
the reference to the recipe, I assume you are asking whether you can map a view onto a Python class using the declarative layer. If so, yes, SQLAlchemy does not care about how the underlying table is implemented, it will issue the same SQL in either cases. ciao, lele. -- nickname: Lele Gaifax

[sqlalchemy] Re: How to get server or dialect version or properties?

2013-04-13 Thread Lele Gaifax
, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: [PROPOSE] Integrate migration support in SQLAlchemy

2010-03-04 Thread Lele Gaifax
(a DAG, introduced by script's metadata) (thanks to Michael's topological sort, btw!) and execute the missing one on a target database. Double value: good documentation, and automatic upgrade of custom's databases. It's GPL, just ask if interested! ciao, lele. -- nickname: Lele Gaifax| Quando

[sqlalchemy] Obtaining primitive columns from a select

2008-07-15 Thread Lele Gaifax
a _raw_columns, or _froms, but it does not seem a clean approach. What am I missing? Thanks in advance for any hint, ciao, lele. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

[sqlalchemy] Re: Defining common columns for a group of tables

2008-05-10 Thread Lele Gaifax
-generated value (they are effectively overwritten by a database trigger, at insert/update time), possibly without resorting to marking them defer on each mapped entity... Any magical shortcut to achieve that? :-) hth, ciao, lele. -- nickname: Lele Gaifax| Quando vivrò di quello che ho pensato ieri

[sqlalchemy] Re: database definitions - was sqlalchemy migration/schema creation

2008-05-09 Thread Lele Gaifax
/UsageRecipes/AutoCode (but note that the current version is not the one attached to the page, but rather lives in a repository on code.google.com). ciao, lele. -- nickname: Lele Gaifax| Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas| comincerò ad aver paura di chi mi copia

[sqlalchemy] Re: Sqlautocode error

2008-04-18 Thread Lele Gaifax
On Fri, 18 Apr 2008 01:06:41 -0700 (PDT) Vortexmind [EMAIL PROTECTED] wrote: On 17 Apr, 18:10, Lele Gaifax [EMAIL PROTECTED] wrote: On Thu, 17 Apr 2008 07:40:02 -0700 (PDT) Either get the trunk of autocode, ... I tried, but http://sqlautocode.googlecode.com/svn/trunk/ grabs the 0.3 SA

[sqlalchemy] (auto-)flush issue

2008-04-16 Thread Lele Gaifax
) ... cross = CrossObj(id=1, index=1) cross.ref = session.query(RefObj).get(1) newobj.other_objs.append(cross) What am I missing? Thanks in advance, ciao, lele. -- nickname: Lele Gaifax| Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas| comincerò ad aver paura di

  1   2   >