Alexander
db.insert(table_name, column=value, column=value) should be significantly faster then entity instance creation
Santosh
Okay thanks
Santosh
I am unable to insert json column, for this
Santosh
But through entity it was possible
Santosh
Got it
Santosh
I need to do json.dumps
Alexander
yes
Yuvraj
i mean i may choose to stores bytes as BLOB
Yuvraj
but how do i actually do that?
Yuvraj
and for the context, im using pony with FastAPI
꧁🦔
Hey! I need to iterate over all the items in table, sorted by one of fields, in chunks. Something like for items in select(..., chunk_size=10).order_by(desc(ts)): for item in items: # 10 results print(item) How can i do this?
꧁🦔
꧁🦔
iterating by one will take too long
Matthew
.page(n) on a query
Christian
PonyORM outperforming other ORMs in TortoiseORM's private benchmarks: https://github.com/tortoise/tortoise-orm#why-was-tortoise-orm-built
Anonymous
Hello. Is there any dev doc for the orm To add more types ?
Anonymous
What is github support mail
Christian
What is github support mail
If you want to get in touch with the developers, you should just ask your question here, they're reading this. There is https://docs.ponyorm.org but no specific documentation on how to extend Pony, if I understand you correctly.
Alexander
Hello. Is there any dev doc for the orm To add more types ?
Hi! Sorry, I don't read the chat regularly this week. Currently, PonyORM was not designed to allow easily adding types by non-core developers. It may be relatively easy to add basic converters for a new type, but complete support requires correct SQL translation of type expressions, and it is non-trivial and usually missed in PRs. As the type system in PonyORM was not designed to be extendable by PonyORM users, it is not properly documented at this moment.
Anonymous
How I help make this orm's better ?
Alexander
Hey! I need to iterate over all the items in table, sorted by one of fields, in chunks. Something like for items in select(..., chunk_size=10).order_by(desc(ts)): for item in items: # 10 results print(item) How can i do this?
You need to select in batches. It is the most easiest if you can order by incremental id: last_id = 0 while True: with db_session: batch = list(select(...).order_by(id).limit(BATCH_SIZE)) if not batch: break for item in batch: print(item) last_id = batch[-1].id It is possible to use the same approach with more complex sort order, but you need to be careful to not miss some items
Alexander
How I help make this orm's better ?
Do you have something specific in mind?
Anonymous
Postgress db type Example : Class revenue (db.type) loss = optional into Amount = required int Time =required And this type class we use it our databases entities
Alexander
You mean composite types or what?
Anonymous
Yeah
Anonymous
Jan.loss ,fav.revenue we use like this Something like this reusable code block type
Anonymous
Support for pickle type
Anonymous
Sorry if I wasted your time ?
Alexander
Probably you can just define entity class for that: class Revenue(db.Entity): loss = Optional(Decimal) amount = Required(Decimal) time = Required(datetime) # and some relations > Support for pickle type You can add serialize(revenue) function
Alexander
Sorry if I wasted your time ?
Can't discuss for long on this week, maybe we can return to it later. Right now I'm not sure the idea is clear enough to be implemented
Alexander
By the way, you can now do: revenue = Required(JSON) and put dict with values into it. It will be serializable out of the box, except time, which is not JSON-serializable by default, but it is possible to use float value of unix timestamp instead
Anonymous
How about HTML data type .
Anonymous
Or XML
Alexander
You can use str for that
Anonymous
Its true but may support auto decode encode on fly
Anonymous
Redis cache feature .
Matthew
those features seem too broad for an ORM to support in its core library
Jeff
hi
Anonymous
Hi
Anonymous
How is every one hère
Anonymous
Anonymous
Nice
Genesis Shards Community
good morning
Genesis Shards Community
por que me sale este error
Genesis Shards Community
Alexander
You need to look at estado attribute definition in Operpag entity, it reseives incorrect first argument Something like: class Operpag(db.Entity): ... estago = Required(1) you need to fix it
Genesis Shards Community
thanks 😉
Christian
@alexey115 Good morning, I think your website certificate has expired again. Firefox is showing me Websites prove their identity via certificates, which are valid for a set time period. The certificate for docs.ponyorm.org expired on 5/9/2021. Error code: SEC_ERROR_EXPIRED_CERTIFICATE
Adrian
Joined to say the same, the cert has expired
Alexander
Thanks for reporting!
Abuelazo
How to do a nesting query
Alexander
What type of a nesting query you want to have?
Anonymous
Probably something like char for char in string for string in strings (Python)
Alexander
select(x for x in X if x.a in select(a for a in A if a.b > 0)) select(x for x in X if not exists(a for a in A if a.b == x.b)) select(x for x in select(a.x for a in A if a.b > 0))
Alexander
Also joins: select(y for x in X for y in x.items) select(y for x in X for in Y if y.x == x)
Abuelazo
I want to obtain information from another table but through an id but the query returns data [1]
Alexander
It does not sound clear...
Alexander
Maybe you can show a query
Abuelazo
select(c for c in tabla.Ventas if int(c.ticket) == int(ticket))[:]
Abuelazo
return Almacen[1]
Alexander
And what do you want to receive from this query?
Abuelazo
get the name found in another table
Alexander
objects = select(c.some_related_object.name for c in tabla.Ventas if int(c.ticket) == int(ticket))[:] for obj in objects: print(obj.some_related_object.name) or select(c.some_related_object.name for c in tabla.Ventas if int(c.ticket) == int(ticket))[:]
Abuelazo
Excellent, thanks
hipertracker
Hi, I am playing first time with PonyORM and I get an error when I try to run show(mary) from https://docs.ponyorm.org/firststeps.html. All worked until I reached to that line
hipertracker
What is AttributeError: 'list' object has no attribute '_translator’?
Alexander
Thank you for reporting! This is a bug. Apparently, if you have a specific instance of entity, show(obj) does not work properly. Until I fix it, you can inspect object by looking at its individual attributes: obj.some_attr
hipertracker
OK
hipertracker
Can a composite_index be unique? (it would be great to add something to docstrings, currently orm.composite_index.__doc__ is blank)
Alexander
Use composite_key(attr1, attr2) for that
hipertracker
It does not use composite_index(att1, att2, unique=True) ?
hipertracker
I do not want to use a composite keys. It a different case. I need a unique index for some columns, not pk
Alexander
composite_key is for secondary unique indexes (because in relation theory there is no unique indexes, just keys). composite primary key in Pony is specified as PrimaryKey(attr1, attr2)
hipertracker
yes, just found thanks to dsql_debug(True). cool. Pony syntax is awesome clean and simple
Alexander
It does not use composite_index(att1, att2, unique=True) ?
Currently this form is not supported, maybe we switch to it later
Alexander
yes, just found thanks to dsql_debug(True). cool. Pony syntax is awesome clean and simple
You can also do with sql_debugging: ... and db_session(sql_debug=True) to output SQL for specific lines of code
hipertracker
sweet