Christian
Released this August, unfortunately tightly coupled with SQLAlchemy but people are already wondering about making the backends swappable: https://github.com/tiangolo/sqlmodel/issues/61
Genesis Shards Community
hi, good morning, helpme, with its: AttributeError: 'Listaprecios' object has no attribute 'first', referer: https://www.einnovas.com/ventas/000309
Genesis Shards Community
pony.orm.core.UnrepeatableReadError: Phantom object Articulo['01000017'] disappeared, helpme please!
Volbil
Genesis Shards Community
no
Genesis Shards Community
it is the code!
Genesis Shards Community
Alexander
The error is caused by the line
print(articulo.idproveedor)
This line is not from the code that you show above
Pony tries to load articulo.idproveedor from the database, but cannot find Articulo with this id
Genesis Shards Community
Genesis Shards Community
If the relationship is there, but I don't know why it doesn't recognize the provider
Volbil
Yeah, accessing object by id probably not the greatest idea
Volbil
You should use something like username of uuid instead and check if object exists
Genesis Shards Community
the error comes up, when I want to print the supplier code that is related in the database, article ---> supplier
Genesis Shards Community
pony.orm.core.UnrepeatableReadError: Phantom object Articulo['01000013'] disappeared
Alexander
How Articulo class is defined? What is the type of primary key, int or str?
Alexander
I suspect you have int column in the database, but specify str in Pony, so Pony expects to find an object with primary key "01000013", but the database returns an object with primary key 1000013 instead
Alexander
This leading zero can be the reason of the error
Genesis Shards Community
is "str"
Alexander
But how it is defined in the database? Can you check the column type in the database?
Genesis Shards Community
Genesis Shards Community
Alexander
This is in Pony. But what do you have in the database?
Which database do you use? PostgreSQL, MySQL?
Genesis Shards Community
Alexander
I mean codigo column in Articulo table
Genesis Shards Community
Genesis Shards Community
Genesis Shards Community
after the get, it finds the product, but when I want to capture the supplier's code, there the error appears
Alexander
Can you check the database, do you really have a row in Articulo table with this primary key:
select idproveedor from articulo where idproveedor = '01000013'
Genesis Shards Community
if it is in the database, it is with all the products
Alexander
You are doing some strange things here:
existencia = Existencia.get(... codigo=a.codigo ...)
...
commit()
exis = Existencia[existencia.id]
...
__codigo = exis.codigo.codigo
if type(exis.codigo.codigo) != str:
__codigo = str(exis.codigo.codigo)
articulo = Articulo[__codigo]
Alexander
exis.codigo should have type str, no? What is exis.codigo.codigo then?
Why are you converting it to str?
Genesis Shards Community
si es str
Genesis Shards Community
Genesis Shards Community
I can't solve it, I got stuck
Genesis Shards Community
Alexander
Before this line, add the following:
codigo = articulo.codigo
cursor = db.execute("select codigo from articulo where codigo = $codigo")
row = cursor.fetchone()
print("articulo codigo:", codigo, row)
And show me the print result
Genesis Shards Community
lo hago ahora, thaks
Genesis Shards Community
thanks
Alexander
Hi, this chat is about PonyORM. For Djongo, please ask in the corresponding group: https://groups.google.com/g/djongo.
David
Santosh
Pony not supported with python 3.10
Volbil
Santosh
Is that a big change from pony?
Volbil
Yeah, as far as I know 3.10 has some breaking changes for api's which Pony uses
Santosh
Oh okay
Christian
Santosh It's described here in more detail. https://github.com/ponyorm/pony/issues/598
Christian
@sashaaero and @metaprogrammer are working on it: https://github.com/ponyorm/pony/commit/8d8360cb4de78fc764c3515478896029c8734410
Ben
I'm getting this very weird error but couldnt capture the exact traceback. Any idea what it could be? It looks cursed.
Alexander
Hi! What database do you use? SQLite?
Ben
Postgres
Ben
The error only seems to appear when running my function in a celery worker and only if the celery worker is using a gevent threadpool instead or processes
Alexander
You can edit pony.orm.dbapiprovider file, and in DatetimeConverter class replace sql2py method to something like that:
def sql2py(converter, val):
import traceback
stack = ''.join(traceback.format_stack())
if not isinstance(val, datetime): throw(ValueError,
'Value of unexpected type received from database: instead of datetime got %s: %s. Stack:\n%s'
% (type(val), repr(val), stack))
return val
It can reveal additional details about the error
Luigi
hi everyone, I am new to ponyorm but i would like to do things right so I am here to ask to the experts.
I have an entity like the following:
class Portfolio (db.Entity):
id = Required (int)
last_date = Required (date)
PrimaryKey (id, last_date)
I would like to extract from a SQLight DB the wallet for a specific id and date, so I wrote the following query:
id = 1
last_date = date (2021,11,10)
result = select (p for p in Portfolio if p.id == id and p.data == last_date)
Unfortunately, no records are returned to me even though I am sure that there is a portfolio in the db that responds to the query (entered by hand via SqlLightStudio)
print (result.first (). id)
also returns the error "AttributeError: 'NoneType' object has no attribute 'id'"
thanks for the support
Luigi
I think it's due to the use of a date field because il I comment out:
and p.data == last_date
it works well ..
Alexander
> even though I am sure that there is a portfolio in the db that responds to the query (entered by hand via SqlLightStudio)
Are you sure that the date entered manually is in correct format?
Can you copy and paste an example of date value from the table that you expect to be found by the query?
Luigi
sometimes a question is the better answer. I made some test and added a record with the orm .. It's selected !!
It's the third row in the above image.
Luigi
these three dates fom me (italian format) are the same ..
Luigi
many many thanks
Alexander
Yes, you need to use the last format
Luigi
I enjoy using this orm, good job!
Alexander
Thanks
Anonymous
hi guys!
Volbil
Hey
Anonymous
would I be able to return postgres data in geometric format?
Anonymous
my data has this format...
Volbil
As far as I know there is no data type for that in pony, but I guess you should be able to do that with string
Anonymous
Volbil
I mean declare this field as string and do data processing inside python itself
Anonymous
is declared as unicode
Anonymous
I need to use this https://leafletjs.com/examples/geojson/
Anonymous
Volbil
Yeah, postgres stores geometry data as bytes blob (or something like that)
Volbil
Maybe there is a way to implement support for that but I'm not sure how it can be done
Anonymous
=(
Volbil
=(
Can you make queries with that data in postgres?
Anonymous
yes
Volbil
Well, in that case Pony probably not the best option for you
Anonymous
I understood