Volbil
There is no other way around unfortunately
Muhammed
Ok, thanks you both
Muhammed
At first, I wanted to use a more practical solution instead of dealing with it one by one.
Genesis Shards Community
hi, one error install pony in windows server
Genesis Shards Community
helpme please!
Alexander
As it says - you are trying to install Pony on python 3.10 which is not released yet
Alexander
For now use 3.9 or lower
Alexander
3.10 support is about to be released
Genesis Shards Community
ok, thanks!
Genesis Shards Community
now its error!
Alexander
I guess it doesnt relate directly to pony. You're trying to insert characters that your database doesnt understand
Anonymous
Need help
Anonymous
House
Volbil
Need help
What happened?
Anonymous
Txt , cvs, Jason xml
Anonymous
I want to process all this file into homogeneous record
Anonymous
Aligning the same customer from different sources together
Anonymous
How can I do that using pony ORM
Adam
load each file and send the data to the DB
Vitaliy
Great news!
Alexander
Hi guys! We just released PonyORM 0.7.15 release candidate 1. This version support Python 3.10. The code was rewritten significantly to use the new ast module from Python 3. All tests are passed. Because of a big change in the codebase, it is possible that some minor parts of functionality are still broken. If you have a possibility, please check if it works for you, so we can fix bugs before stable release. You can install it from PyPI using the command pip install pony==0.7.15rc1 https://pypi.org/project/pony/0.7.15rc1/ https://github.com/ponyorm/pony/releases/tag/v0.7.15rc1
Radim
Hello Alexandr, thanks for the release! could you please also add a 0.7.15 or 0.7.14 wheel to pypi?
Genesis Shards Community
thanks!
Radim
the last wheel available is 0.7.6
Radim
ah I see its rc, so maybe add that after some "users testing"
Alexander
Does wheels format have benefits? In my understanding, wheels is mostly useful for compiled binaries, and Pony distributive is source-only
Radim
you are right, I just have installer script which downloads pypi packages including pony and am using flag —only-binary=:all: and my wheelhouse folder ends up with pony version 0.7.6 which is confusing, because its older version.. if there were no wheels the pip should fallback to tar.gz which is totally ok with pony as its source-only, no complied submodules
Radim
so maybe removing the wheels(if its possible) will do too
Radim
but its just me, I have asked for convenience, it has priority zero
Alexander
Thanks for the explanation, in that case we probably should add wheel when making a stable release
Radim
sounds cool, thanks
El Mojo
YaaaaaY
Broom
I will appreciate a guidance to that
Broom
Am new to it
Christian
Am new to it
This is a group for PonyORM, you can easily find tutorials for file I/O online: https://www.pythontutorial.net/python-basics/python-read-text-file/
Radim
you first need to know how to parse each file type to lets say list of dicts and once you have that you can come again to discuss more details on db part with pony
Broom
Okay thank
Ben
Hi! Is there a way to fix the PhantomObject errors? Like a way to iterate through some relation and remove the objects that aren't actually there?
Alexander
Probably pony should check this type of errors less aggressive. For now, you can use db_session with optimistic=False option.
Ben
but once identify, how do I remove them form the collection?
Ben
I cant get the object, so I cannot pass it to thing.collection.remove(obj)
Alexander
If I understand correctly what you are speak about, the object is already removed at this moment
Alexander
PhantomObject exception means that the current db_session read data of some object and then encountered it was removed by a concurrent transaction
Ben
Aaah, yes but it is removed from the table but not from the intermediary table. I have a table A for which objects have a collection of B (from table B). Some of my A objects have reference to an object B that is not in the table B anymore. I can see this in the A_B intermediary table.
Ben
for some reason the data got corrupted and the constraint violated, but now I need to fix the actual data
Alexander
In this case, I think you need to execute raw SQL query, something like db.execute(""" delete from A_B where b_id not in ( select id from B ) """) But be careful to not accidentally delete the other rows
Ben
Ok so I found a workaround, trying to list of all of the Bs in every A works fine. However if for every B I try to get the B.name (within an except) then it will fail only if B does not really exist, and then I can pass by object B to A.collection.remove(B)
Ben
It only works with optimistic=False as you suggested, which had me scratching my head for a while but as soon as you pointed it out then I could progress. Thanks a lot!
Oualid
morning, how is the combination with FastAPI !! i see it's complicated some how !! pydontic and so on !!
Christian
morning, how is the combination with FastAPI !! i see it's complicated some how !! pydontic and so on !!
Hi Oualid, it's not that complicated, but you will have duplicate models because of the way Pydantic handles its schemas. https://docs.ponyorm.org/integration_with_fastapi.html
Christian
More important, in my mind, is that the current version of PonyORM is not build with async in mind, if this is important to you, you might want to look at https://sqlmodel.tiangolo.com/
Alexander
You're not forced to work with async in FastAPI. So it's completely usable imo.
Christian
You're not forced to work with async in FastAPI. So it's completely usable imo.
I agree! I'm using it like this as well. I would think that most people new to FastAPI don't really need its async capabilities. But if you do want async in an API, I would think that it is on the database connection?
Alexander
I don't have big understanding how it should be done in a perfect way to be honest. Transactions are atomic, which is not really mix well with async in my view. So why everything "should be async" nowadays is a big question for me.
Radim
I am using pony in otherwise fully async project, and if I follow the rule, that db_session does not has any awaits in it, it works great and stable
Radim
waiting for network io - like communicating with multiple remote servers at once
Bob
Hey guys, I noticed some inconsistent behavior between pony and postgres For context, Pony is the only way I add new people to people table I'm able to query and find an entity using person = Person[zipcode,name] Once I do that, I can correctly print Person attributes using person.age, person.height, etc. This tells me the person is in the db However, I need pandas.to_sql() to perform other inserts on another table that has a FK relationship to Person When I run the to_sql() function, I get an IntegrityError saying that the person does not exist in people table But that's weird, the person is already in the db. If they weren't, how would pony be able to tell me their correct attributes? So I pull up a terminal and use psql t9 access my db. I perform a select query using the persons name and zip code, the primary key. To my great surprise, the query returned 0 results. This tells me the person is NOT in the db. How can an object simultaneously be both in the db and not in the db? If the person is not in the db, where does pony get their age and height from? Surely pony didnt make up the correct data out of thin air
Bob
The only possibility I can think of is that while postgres, psql are both case-sensitive, maybe pony is not? So using psql I tried "select * from people where lower(name) = lower("john johnson") but this also pulled up 0 results Hoping someone here might have some ideas as to what is wrong with my implementation
Vitaliy
Do you flush/commit or close db_session after entities creation? If not, these objects stored in memory cache.
Radim
to me it seems like the people are not commited yet, after you trying to work with them again.. maybe try to interleave your code with db.commit()
Bob
oh its db.commit()? I was using from pony.orm import commit commit() I use the db_session decorator on small functions that access the db, I don't think I should have any issue with the way my db_session s are set up let me try your way
Bob
same behavior I've tried commit(), flush(), db.commit(), db.flush(), all have same results
Bob
noteworthy, if I try to add the person again I get a CacheIndexError so you must be correct that the entity is in my local cache but not in the db
Bob
is there a way I can dump the cache and then try Person[pk] again to see if I get an ObjectNotFound?
Alexander
Hey guys, I noticed some inconsistent behavior between pony and postgres For context, Pony is the only way I add new people to people table I'm able to query and find an entity using person = Person[zipcode,name] Once I do that, I can correctly print Person attributes using person.age, person.height, etc. This tells me the person is in the db However, I need pandas.to_sql() to perform other inserts on another table that has a FK relationship to Person When I run the to_sql() function, I get an IntegrityError saying that the person does not exist in people table But that's weird, the person is already in the db. If they weren't, how would pony be able to tell me their correct attributes? So I pull up a terminal and use psql t9 access my db. I perform a select query using the persons name and zip code, the primary key. To my great surprise, the query returned 0 results. This tells me the person is NOT in the db. How can an object simultaneously be both in the db and not in the db? If the person is not in the db, where does pony get their age and height from? Surely pony didnt make up the correct data out of thin air
Hi! If you do p = Person(zipcode=..., name=..., age=..., height=...) it creates an object in memory. You can retrieve page.age, p.height etc. from this object even before it was stored in the database. After flush() or db.flush() the row is inserted to the database. Usually, it is unnecessary to perform flush() manually because it is performed automatically before commit or before any select. After the flush, the row is inserted into the database. But it is still invisible to other connections because the transaction is not completed yet. If you have exited db_session or manually performed commit, the row becomes visible to other connections. If it is still invisible to other connections, it may mean that you insert a row to one database and perform a select from a different database.
MohammadReza
Hi 👋🏼 I’m a newbie in Pony ORM, and I want to know how to use migrations in Pony?
El Mojo
Hi 👋🏼 I’m a newbie in Pony ORM, and I want to know how to use migrations in Pony?
for the moment, migrations are not ready on the stable version. only available on the dev branch.
MohammadReza
Is there any way to write migrations manually?
El Mojo
Is there any way to write migrations manually?
yeah ; you do it with the tools you want ; dbmate or flyway
MohammadReza
Thanks 🙏🏼
Amirabbas
yeah ; you do it with the tools you want ; dbmate or flyway
Could please explain more or give a link of an example of a migration file using ponyorm ?
El Mojo
you can find docs on how to do it on the github of dbmate project or the docs of flywaydb