SlavaMGTU
and i can't write None
SlavaMGTU
Label(name = line['name'], path = line['html'], parametrs = None, parametrs_ex = None, description=None)
ValueError: Attribute Label.parametrs is required
Alexander
Because str values are automatically stripped by default, to avoid confusion when a user accidently add a space to the end of the value
If you want to store spaces as well as empty string, you can declare the attribute as
Optional(str, autostrip=False)
SlavaMGTU
Thank you for your advices, but I'm fixing other people's code. It is very buggy incomprehensible program, just in case, I wrote down "Hull" everywhere
Daniel
can you please create pony orm that support async dorectly
Daniel
i will grladly move all my project
Daniel
because mostly i work an async framework as required in my work
Amaro
Had to use dead snakes because a lack of 3.11 support. Looks like a real problem...
Alexander
We will try to make a release during the following week.
Wizuba
Hi everyone, how to count table's elements by one attributes in Pony ORM ?
Like I want to count male student in the school table in my db.
Wizuba
yg
https://github.com/pgvector/pgvector-python/blob/master/examples/pytorch_image_search.py
hello, i am using type [vector] which extended by pgvecror, but i don't know how to use this vector type with pony, please help me, thanks~
Permalink Bot
Alexander
yg
ok, thank you, this means i can not create table by class xxx(db.Entity) ... ?
Alexander
yg
got
Naroj
Hi folks, a quick question. I noticed that updating a boolean field only works one-way. From false to true works as expected (in Sqlite). Going the other way around doesn't update the field, while the ORM returns a success. I worked around it by switching to an int and enforcing a 0 or 1 from the application. Is this known behaviour?
Alexander
Naroj
I don't have telegram for my desktop yet, so pasting code around is a bit cumbersome. I'll try to reproduce later today with concrete code.
Alexander
Naroj
Thank you for this awesome ORM. I'm really enjoying it so far
PSoftware 👨🏻💻
hi
PSoftware 👨🏻💻
PSoftware 👨🏻💻
PSoftware 👨🏻💻
for waths?
PSoftware 👨🏻💻
help me! please!
PSoftware 👨🏻💻
Elraro
Which version of ponyorm are you using?
PSoftware 👨🏻💻
pony==0.7.16
Elraro
pony==0.7.16
https://github.com/ponyorm/pony/issues/443
Elraro
Not implemented yet
PSoftware 👨🏻💻
similar, for an solution?
Matthew
Do one update query per item, in a loop
PSoftware 👨🏻💻
ok, thanks!
Amaro
yg
hello, my postgresql table defined as follow:
class AutoParts(db.Entity):
'''auto parts'''
code = Optional(str, default='')
name = Optional(str, default='')
brands = Optional(str, default='')
,and when i execute this query, report error:
Column count does not belong to entity AutoParts
AutoParts.select_by_sql("SELECT COUNT(*) FROM public.autoparts WHERE brands LIKE '%AAA%' and code like '%BBB%'")
plz help
PSoftware 👨🏻💻
hi, good morning guys
PSoftware 👨🏻💻
how to capture the return of the id after inserting a record?
Vitaliy
Hello! You need to do flush or commit to get it
PSoftware 👨🏻💻
Vitaliy
https://docs.ponyorm.org/working_with_entity_instances.html?highlight=flush#saving-objects-in-the-database
PSoftware 👨🏻💻
PSoftware 👨🏻💻
solved, thank you very much!
Thiago
Hey! it is possible to get a user User.get(email="email@email) with the roles. But that only generates a "select with join"
Thiago
oi
Alexander
Alexander
What is the problem?
Thiago
I'm logging in, I would like to recover the user with the roles.
Thiago
are two separate entities in two tables
Thiago
I managed to do it in 2 steps, 1- get user 2- get roles, this generates 2 select
Thiago
I would like to get it with 1 select, using *join*
Wizuba
Hi everyone I got 2 questions and I need your help.
1- Does pony ORM have a Choices field ??
2- Does pony's Entity class have any method to validate data before it saves them in db ?
Radim
there is something like py_check for validations
A
Hi everyone
Just have a question
How does pony handle db migrations?
Does generate_mappings do it?
Suppose I am adding 2 columns to a model will that get changed in the db by pony?
Alexander
Right now pony does not handle migrations unfortunately. You need to use an external tool like FlywayDB or PonyUp and write alter table commands manually
A
Ok thanks for the info 👍
Maury
hello, sorry for my question but im looking for a way to get the old values of an element in the 'before_update' or after_update methods
class ReceiptDetail(db.Entity):
_table_ = 'receipt_detail'
id = PrimaryKey(uuid.UUID, default=uuid.uuid4)
receipt = Required(Receipt)
accounting_account = Required(
AccountingAccount, column='accounting_account')
description = Required(str)
amount = (Decimal, precision=14, scale=4)
created_at = Optional(datetime)
updated_at = Optional(datetime)
def before_update(self):
#verify if the new amount is greather or lower than the original to do the voucher update
# if self.old_values.amount > self.amount:
#verify do some stuffs
any help is welcome, thanks
Maury
the def before_update(self): function its just an example of what im looking for
Matthew
I think you would need to store the old values explicitly on the object before any updates
Ian WSAF433
Does PonyORM have a GitHub Sponsors section? It could be a good way to help fund development and let people pay a bounty for certain pieces of work. For example: I'd be willing to pay some amount (let me know how much!) to get the Python 3.11 PR #671 completed and merged into a new release.
https://github.com/sponsors
Ian WSAF433
I am getting stuck trying to figure out an issue with reverse attributes. I have a "Milestone" class that describes a "start" and "end" period for a milestone. In the details it consists of two attributes "planned" and "actual", which are each of "DateSet" type. It looks like PonyORM doesn't like the reverse attribute for both "panned" and "actual" to be the same, but I don't know what else I would set them to. Any suggestions?
Ian WSAF433
The above results in the exception:
pony.orm.core.ERDiagramError: Inconsistent reverse attributes Milestone.actual and DateSet.milestone
PSoftware 👨🏻💻
Hi, I have this error, why should it be?
valueError: invalid literal for int() with base 10: ''
Radim
you are trying to cast empty string to integer
PSoftware 👨🏻💻
How to know which field of the table it is?
Radim
the traceback of the error will tell you exact line of code
PSoftware 👨🏻💻
In this case I am making a query to a table, and it does not tell me which field it is
Radim
do you have any try except block around this query? if so, just remove it temporarily, it will show you the traceback
PSoftware 👨🏻💻
PSoftware 👨🏻💻
I already found the mistake, thanks!
Josh
struggling to find any reference for this issue: ImportError: cannot import name 'PGStrConverter' from 'pony.orm.dbproviders.postgres'
Josh
I get that on the bind method I have for cockroach.
Josh
db.bind(provider='cockroach',
user=os.getenv('CRDB_USER'),
password=os.getenv('CRDB_PASSWORD'),
host=os.getenv('CRDB_HOST'),
database=os.getenv('CRDB_DBHOST'), )
PSoftware 👨🏻💻
Good morning
PSoftware 👨🏻💻
How can I test my code, can someone explain it to me or give me an example?
PSoftware 👨🏻💻
I need to do my unit tests and I don't know how, helpme!
A
Hi
I am using select_by_sql for a join.
I am joining with 3 tables.
But since we need to specify the entity when we call the function i am only getting attributes of the entity I specify.
I want all my attributes. How to make this work