Tom
Hi, what’s the correct way to patch out an entity for testing?
Alexander
Wdym
Alexander
You can create an in-memory SQLite database for a test and pre-fill it with specific entity instances
Tom
Wdym
I’m trying to patch out an entity entirely for a unittest, with an @patch decorator, but when it hits the patch it binds the db and generates mappings
Tom
Alexander
Currently not, I recommend to bind outside of entity definition file
Tom
Ok will give that a shot thanks
Tom
Thanks for the help! Making progress! I think because I'm using an in-mem DB for the test cases, I can't seem to use objects between dbsessions. E.g. if I create an object and commit in the suite's setUp step as self.entity = Entity(), I can't access self.enttiy in test_x, but I can do an entity = Entity.get(), just want to make sure I'm not doing something wrong. Also, where should the bind go? If I just throw it into any of my files as soon as I import into the test file the bind occurs, and then when the bind is attempted in the test file it fails because the bind already exists
Tom
Alexander
To existing entities
Matt
Hey guys, just wanted to let you know that the online editor seems to be down 🙂 {"msg":"Server error”} when trying to create a diagram or save.
Christian
Same for me: Sporadic errors (one on logging in to editor.ponyorm.com) that return json {"msg":"Server error"}, but could login after reload. Now the tabs ("Models", "SQLite",...) display "Something went wrong"
Alexander
Thank you for reporting! Should work now
Matt
Yep, you fixed it! Thanks Alexander!
Radim
Hello does entity.collection.clear() delete items of the collection if the item has no further references?
Alexander
It's a magic. I forgot how is is called in Pony... Maybe another Alexander can name it
Diego
hello
Diego
is there any way to update a model after is first created?
Alexander
Built-in Pony - no.
You can use some migration manager and make migrations by yourself.
I used Flyway with Pony at some project - it worked pretty well.
Diego
thaaanks!
Vladislav
Diego
I understand that they don't
SlavaMGTU
I'm looking for an Entity-Relationship Diagram Editor. I need to convert SQLite code to diagram. How can I do that? Tell me please.
Diego
hello, is there any place where i can find bechmarks of the ORM?
Volbil
Volbil
M❄️hdi
how is better?
the more or the less? (vertical bar)
Volbil
Volbil
There is table with numbers and description
Diego
cool
Diego
I have tried to do my own benchmarks, and the results are not the same :(. Maybe the way i am accessing pony is wrong
Diego
Volbil
Volbil
[:] I mean
Diego
db_session is required when working with the database. I get this error
Volbil
Also you probably need to do loop under the session if you want to do any changes
Volbil
Move for loop one tab right and remove [:]
Volbil
I think it would provide better results
Diego
ohh i get you
Diego
i tried that before, it performs the same or a little worse
Diego
I'm returning 5000 objects from my api. Pony does it in 90ms and django orm in 80.
Diego
Diego
Diego
im using in both differente postgre db
Volbil
Volbil
Returning this many objects is not great idea
Diego
what i found is that pony does way better in cold starts. but django does better in the following requests
Diego
I know i should use pagination in prod. Im just trying to benchmark
Stone
hey bois, is there asyncio ports of Pony?
Stone
Anatol
Приветствую,
А как правильно перегнать в словарь результат select?
К примеру, не срабатывает с
x = select(d for d in DataSession)
to_dict(x)
и в варианте select(d for d in DataSession)[:] тоже
Entity instance or a sequence of instances expected.
to_dict из from pony.orm.serialization import to_dict
Alexander
Alexander
Alexander
:)
Christian
Hi. I'm trying to figure out the optimal way to combine flask+pony+pytest for testing. I'm using the suggested techniques in https://github.com/ponyorm/pony/issues/32 but I'm still running into the problem of having a db-factory function generating different db objects that mess my tests up. My solution is using the @cache decorator to turn the db-factory function into a singleton. Is this the way to do this or am I doing something overly complicated here?
Alexander
I would end up with a singleton too.
Christian
Alexander
The only thing I would go with a common singleton implementation
_db = None
def get_db():
global _db
if _db is None:
_db = Database(...)
...
return _db
Cause it may be confusing for other devs with a `@cache`one.
Christian
There is no way to call a PonyORM Database by a unique identifier, right? For Flask, the idea of database URIs that can be attached to the current_app and called when necessary from the context seems the most elegant solution.
Alexander
Built-in - no. You can create own mapping.
Nikita
Hello everybody, is there any information about multiple files for models? I'd be very gratitude if you tell me how to separate models or it's bad idea or you have link to topic in docs
Christian
...and you could leave out __init__.py, but I find it nice to import all models from just src.models
Nikita
Christian
Yes.
# --------------------
# file: /src/models/animal.py
from src.models import db
class Duck(db.Entity):
firstname = Required(str)
Christian
In that way everything maps to the same Database object.
Nikita
You're the best thanks a lot
Christian
Welcome! :)
Damiano
raise OperationalError(e)
pony.orm.dbapiprovider.OperationalError: database is locked
Damiano
First time ever getting this error. What's this?
Ziya
Damiano
aswiro
What type of data should I specify when creating a table?Hi, tell me I need to write down the number 1009998887766.
Volbil