Noname
I tried with sqlite and memory DB like in example - same result
Volbil
Strange, I never encountered such behaviour before
Volbil
What python version you using?
Noname
3.11
Alexander
Did you override select by any chance?
Alexander
Oh, wait. Pony doesn't support Python 3.11 yet.
Noname
😂
Noname
Course, that I study - worse that I think)
Noname
What version can advice?
Noname
3.10 or earlier ?
Noname
"Can be installed on python 2.7 or 3" - official doc, all info about versions)
Alexander
3.6 - 3.10 included
Alexander
Yeah should be updated
Evan
is the idea to support 3.11 in the future? Also I tried to load a table into a dataframe using the following query but that errors out @orm.db_session def load_table_into_df(table): attrs = [x.name for x in table._attrs_with_columns_] q = orm.select((getattr(d, a) for a in attrs) for d in table) # << This fails df = pd.DataFrame(q, columns=attrs) return df
Evan
is there an easy way to select all _attrs_with_columns_ in a query?
Evan
something equilvalent of select * from table
Evan
ended up with something like this @orm.db_session def load_table_into_df(table): attrs = [x.name for x in table._attrs_with_columns_] data = [el.to_dict() for el in table.select()] df = pd.DataFrame(data) return df
Henri
I can suggest using some migrations manager which runs raw sql
Are migrations still on the Pony road-map for the next future? Or is there a recommended migration manager (postgresql).
Alexander
I really liked firebase
Alexander
Migrations are almost done for postgres almost 2-3 years, to be honest.
PirraToZ
How to add multiple objects to a table at once?
Alexander
At this point it would be not fair to give any promises about its release. Since we gave a lot of them.
Alexander
https://stackoverflow.com/questions/51655297/python-pony-orm-insert-multiple-values-at-once/51670740#51670740
PirraToZ
https://stackoverflow.com/questions/51655297/python-pony-orm-insert-multiple-values-at-once/51670740#51670740
How can I get these values ​​from the list? exp: ids = [1,2,3,4,5,6,90] User.select(lambda u: u.id in ids) # this not work
Henri
Migrations are almost done for postgres almost 2-3 years, to be honest.
So it's available on a branch?
Alexander
So it's available on a branch?
Yes, it's a bit outdated in terms of python support. I guess it stuck at 3.9 version or smth. If I remember correctly the branch is orm_migrations. It supports most of common actions, not tested on some big composite changes. Mostly tested on PostgreSQL and SQlite. Should also somehow work for both Oracle and MySQL.
Alexander
That would be nice. Actually migrations and python bytecode support don't intersect in general, so maybe simple merge\rebase should do the job.
Alexander
Oh yeah, you're right. migrations_dev is the branch you need. orm_migrations is a super old migrations approach which was declined.
PirraToZ
Not sure why... Seems like it should
I would like to make a selection by certain id
How can I get these values ​​from the list? exp: ids = [1,2,3,4,5,6,90] User.select(lambda u: u.id in ids) # this not work
Try this: ids = [1,2,3,4,5,6,90] values : list["User"] = [ User.get(id = id) for id in ids ]
this many iterations)
Yes 😅 I don't know if PonyOrm support other method if you found tell me to learn also..
Daniel
Good day everyone, I just started using ponyorm my question is can I separate my models into different files
Daniel
Like all the entity that belongs to use in one file and all the model that belongs to post in another file
Alexander
Whats the problem uve met?
Daniel
Please... I want to ask if ponyorm is still being maintain😕, I want to use it for a big project, that will be hard for me rewrite. Thanks
Daniel
According issues from the pony repo the cockroachdb is no longer supported.
Daniel
I want to know how true
Daniel
And lastly is there a migration tools
Alexander
Honestly, it is maintained badly. I had almost no resources to work on PonyORM lately. I believe it should change now, as I can work on Pony again. But if I were you, I'd take this with a grain of salt. I suggest you see if we could release a new version of PonyORM with Python 3.11 support in a few days, and if not - consider some other options to be safe. I seriously plan to return to work on Pony again. But it is better not to rely on specific dates. The support of CockroachDB should be restored in the same release as adding Python 3.11 support. Regarding migrations, I cannot promise specific dates for them.
Volbil
Honestly, it is maintained badly. I had almost no resources to work on PonyORM lately. I believe it should change now, as I can work on Pony again. But if I were you, I'd take this with a grain of salt. I suggest you see if we could release a new version of PonyORM with Python 3.11 support in a few days, and if not - consider some other options to be safe. I seriously plan to return to work on Pony again. But it is better not to rely on specific dates. The support of CockroachDB should be restored in the same release as adding Python 3.11 support. Regarding migrations, I cannot promise specific dates for them.
I've used Pony as my main orm since 2020 and still having couple projects in production using it. However I've switched to async code for my projects around year ago and it wasn't suitable for them so I had to switch to other orm. None of them provides such flexibility and comfort I've had with Pony and it still hold a special place in my heart. I'm looking forward to see what you can do with and how you can improve this outstanding orm and wish you luck!
Alexander
Any (coding) help would be appreciated
Edward
But if the message is >aa
Brandon
Is this an appropriate place to ask a question regarding relationships and cascade delete?
Lennart
@akozlovsky Is it possible for you to take a look at this PR: https://github.com/ponyorm/pony/pull/677 It is a fix for this issue: https://github.com/ponyorm/pony/issues/675 For the record, it is an issue we are hitting in production. I have deployed a work-around in my system, but it would be nice to slove this properly.
Alexander
@akozlovsky Is it possible for you to take a look at this PR: https://github.com/ponyorm/pony/pull/677 It is a fix for this issue: https://github.com/ponyorm/pony/issues/675 For the record, it is an issue we are hitting in production. I have deployed a work-around in my system, but it would be nice to slove this properly.
Thank you for attracting my attention to this very important issue and the PR. I'll try to handle it today. Need to think a bit about the proposed fix and whether it is completely correct
Alexander
@akozlovsky Is it possible for you to take a look at this PR: https://github.com/ponyorm/pony/pull/677 It is a fix for this issue: https://github.com/ponyorm/pony/issues/675 For the record, it is an issue we are hitting in production. I have deployed a work-around in my system, but it would be nice to slove this properly.
The identified reason is correct, and the provided test is very helpful, but the proposed solution does not look complete; it reduces the number of cases when the bug appears but does not eliminate them. It does not fix the situation when a new function with the same id has the same code object as the garbage-collected function (but contains different closures). Also, it can lead to some memory garbage remaining uncollected. The correct solution should use weak refs and discard translators that refer to garbage-collected functions. I'll try to come up with it.
Evan
hey guys quick question - is it possible to create a constraint where say I have two columns but not both can be filled in - one or the other have to be filled in
Evan
smth like this https://stackoverflow.com/a/960591/1764089
Alexander
If your database allows that, you can manually add constraint: alter table ... add constraint ... And also add before_insert/before_update handlers to the entity with a check
Evan
thank you
Karsten
Hello everyone, I just switched from Python 3.10 to Python 3.11.2. Suddenly get an error in a simple select query. Does somebody has any idea ?
Christian
Hello everyone, I just switched from Python 3.10 to Python 3.11.2. Suddenly get an error in a simple select query. Does somebody has any idea ?
Python 3.11 is not yet supported, unfortunately. @metaprogrammer said he wanted to fix this as soon as he gets around to it.
Evan
how can I choose the schema I create my tables in?
Evan
seems like this is all I need to do? class Person(db.Entity): _table_ = ("my_schema", "person_table") name = Required(str)
Alexander
Yes
Evan
do the a if b else c expressions work now? - I tried them and got a "this expression is too complex" message https://stackoverflow.com/questions/16115713/how-pony-orm-does-its-tricks#comment59802214_16118756
Alexander
I works if you supply query as a string instead of a generator code select((x.a if x.b else x.c) for x in X) - does not work select("(x.a if x.b else x.c) for x in X") - works
Evan
Ok got it
Evan
yeah that worked - though got a weird error when I wrap it with orm.min it returns '\n' but if I wrap an orm.select() with orm.min it returns the correct value
Evan
Also getting an ERDiagramError: Entity Table already exists when I define define tables in different schemas ie model1.py from utils import db class Table(db.Entity): _table_ = 'schema1', 'table' model2.py from utils import db class Table(db.Entity): _table_ = 'schema2', 'table'
Evan
i'd expect this to work but it complains
Evan
when i later do import model1 import model2
Evan
posted the question here if easier: https://stackoverflow.com/questions/75602565/in-ponyorm-do-i-need-to-declare-classes-with-different-names-even-if-they-belong
Alexander
Why you are trying to re-create same entity?
Alexander
Ah, different schemas, i see
Alexander
It says about class name, it should be different
Evan
the class names should be different right?
Alexander
Yes