aldo
class Thumb(db.Entity):
_table_ = 'thumbnails'
Id = orm.PrimaryKey(str)
Image = orm.Optional(bytes)
changed the definition and now works fine (when everything fails, read the manual) :)
Nick
Hi Nick! Thank you for this! I can review it on Saturday
Found some interesting stuff after spending some time looking at the decompiler, running against our codebase, and got a couple of tests that capture the issues.
It looks like python 3.12 will generate different bytecode depending on whitespace, and I was able to write a couple of tests that will pass on 3.10, but fail on 3.12 (pony misses part of the AST when decompiling the bytecode)
Was wondering if anyone more famililar with the decompiler would be able to take a look and take over or offer some pointers.
https://github.com/ponyorm/pony/pull/741/files#diff-5d718a04b57f46be1e1d57d8aafeea6fe8223ca90ce99c1eaeda219d5837b6f4R257-R258
Монро
🍽 Кулинарный лайфхак! 🍽
🎄Розмарин — это ароматная и универсальная специя, которая идеально дополняет множество блюд. Вот список блюд, к которым он подходит лучше всего:
🍖 Мясные блюда: жаркое из баранины или ягненка, свинина, говядина.
🐟 Рыба и морепродукты: запеченный лосось или другая жирная рыба, креветки на гриле, рыбные супы или бульоны.
🥔 Овощи и гарниры: запеченный картофель (дольки или целый картофель), тыква или кабачки, грибы. ♥️
#КулинарныеСоветы #Розмарин #ИдеиДляКухни
Светлана
Есть места на УДАЛЕНКУ с хорошим доходом.
— Занятость 1-2 часа в день
Пишите в ЛС "+" за деталями!
Светлана
Есть места на УДАЛЕНКУ с хорошим доходом.
— Занятость 1-2 часа в день
Пишите в ЛС "+" за деталями!
Светлана
Есть места на УДАЛЕНКУ с хорошим доходом.
— Занятость 1-2 часа в день
Пишите в ЛС "+" за деталями!
aldo
def location_summary(data):
location, file_id = data
return (
location.to_dict(exclude=('file',))
| {'file': file_id}
)
def location_select():
return [
location_summary(obj)
for obj in orm.left_join(
(x, x.file.id)
for x in db.Location)
]
this would work...
Alexander
Hello. Try
[obj.to_dict() from obj in orm.select(x for x in db.Location).prefetch(db.File)]
aldo
still see the queries, just now with a different id order
SELECT "id", ..., "location"
FROM "File"
WHERE "location" = ?
LIMIT 2
and then _after_ those queries see SELECT "id", ..., "location"
FROM "File"
WHERE "id" IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
[93, 495, 1020, 2073, 2307, 2588, 2611, 2785, 2984, 5003, 5817, 8201, 8435, 11331]
where those ids are the ones that do have relationship
aldo
by the way, there is no issue for (n,m) or (1,n) relationships
Radim
Hello, any update on python3.13 support?
Alexander
Sorry, was overloaded at work. I hope to be able to do it tomorrow
Radim
Hello Alexander, have you got a chance to take a look to determine how much effort should go to new release? thanks a lot
Alexander
Working with bytecode is always unpredictable
Alexander
However, I have a question how many of you migrated to 3.13 already? On my work I still cant pass 3.10 cause of dependencies..(
Radim
I am on 3.12, only blocker currently is pony, but thats just me :)
Ben
I am on 3.11 blocked by the pop jump if none issue to move to 3.12
Timofei
aldo
good morning, ¿should use on_connect() decorator to load extensions? for example @db.on_connect(provider='sqlite')
def sqlite_case_sensitivity(db, connection):
connection.load_extension(sqlite_icu.extension_path().replace('.so',''))
Amo
Hi, how can I load an complete sql file through pony in my database? E.g. I have a sql dump as backup and want to refill my database
Amo
I use db.execute() now and read line by line
Alexander
You sure you need Pony for this? It would be much easier to apply dump directly
Amo
My unit tests use pony and I have all the infrastructure to connect to the dB server etc in pony
Radim
Hello @metaprogrammer, any news on py3.13? thanks in advance
Alexander
Wasnt there a PR for 3.13 support?
Alexander
@luckydonald hello. If I'm not mistaken you were the one who made migrations approach.
How did it end? Did you make it all by yourself or you used our migrations branch?
Lucky
I did not use migration branch. I use regular ponyorm.
The thing is at https://github.com/luckydonald/pony_up
Lucky
Lucky
Last time I used it, it worked well.
Alexander
Aight thanks!
Please
"select"
function not works fine when pass lambda in it
This happens only with python 3.13
In python 3.12 works fine
Alexander
Alexander
Although progress started
Radim
Hello, @metaprogrammer any updates on py 3.13? thx
Alexander
It's me who implements this.
For now I'm kinda stuck at some bug(
Henri
@metaprogrammer I added stubs with type annotations. They work fine with pyright/pylance. With mypy there are some issues and I don't think they're solvable without fixing at least 1-2 issues in mypy. Do you want a PR?
Henri
Here is the repo: https://github.com/henri-hulski/pony/tree/stubs
Henri
In the test_types branch I applied the annotations directly to the code to test integrity.
Alexander
Thank you! I'll look into it
Amo
Hi, does pony serialize the access to a sqlite dB for multiple requests? For example if I have a website and multiple users using it to store data?
Jeff
Does Pony have strawberr-gql support
aldo
good morning, i'm seeing a weird bug with inheritance. the value of the classtype is not retrieved from db from pony import orm
from pprint import pprint
def create(db):
class Location(db.Entity):
connection = orm.Set('Connection')
@classmethod
def serialize(cls, ids):
return {
x[0].id: x[0].custom_summary(*x[1:])
for x in orm.left_join((x, x.connection) for x in cls if x.id in ids)
}
def custom_summary(self, connection):
origen = {
'classtype': connection.classtype,
'id': connection.id,
}
return self.to_dict() | {
'origen_model': origen,
}
def to_dict(self):
return super().to_dict(exclude=['connection'])
class Connection(db.Entity):
location = orm.Optional('Location')
class Antena(db.Connection):
pass
class Wireless(db.Connection):
pass
db = orm.Database()
create(db)
db.bind(provider='sqlite', filename=':memory:', create_db=create)
db.generate_mapping(check_tables=True, create_tables=True)
with orm.db_session:
antenna = db.Antena()
location = db.Location()
location.connection.add(antenna)
orm.set_sql_debug(debug=True, show_values=True)
with orm.db_session:
location = db.Location[1]
loc_serial = location.serialize([location.id])
antenna_data = loc_serial[1]['origen_model']
pprint(antenna_data)
antenna = db.Connection[1]
pprint(antenna.to_dict())
aldo
i'm on version 0.7.19
aldo
found a fix class Location:
def custom_summary(self, connection):
origen = {
'foo': connection.foo, #¡important!, before classtype access
'classtype': connection.classtype,
'id': connection.id,
}
...
class Connection(db.Entity):
location = orm.Optional('Location')
foo = orm.Optional(str) # just to have something to access
this way it does make a select for Connection table to retrieve the data
Radim
Hello, how does it seem with py 3.13 support, any news?
Radim
alrighty, thanks for honest response
Vlad
Are there plans to support import/export of designer models in PonyORM online editor (at least for the commercial version)?
Alexander
Hi Vlad! Recently, the development of PonyORM and its online editor stalled due to a lack of time for core developers. I believe it will finally change in the near future, as I will have the opportunity to return to active development. Initially, I'll plan to focus on PonyORM itself, so I don't expect any significant improvements to the online editor soon. Still, I'm interested in hearing what type of import/export you have in mind. Can you explain it in more detail?
Timofei
Vlad
Hi Vlad! Recently, the development of PonyORM and its online editor stalled due to a lack of time for core developers. I believe it will finally change in the near future, as I will have the opportunity to return to active development. Initially, I'll plan to focus on PonyORM itself, so I don't expect any significant improvements to the online editor soon. Still, I'm interested in hearing what type of import/export you have in mind. Can you explain it in more detail?
We use the design model for maintaining our ERD, and generating the ORM code. Basically, the design model is, kind of, the ground truth for us.
The generated ORM code is stored in the project's source control. So we would like to store the design model there as well, so that both could be synchronized.
We know that snapshots can be created in the editor, but this means that extra effort needs to be introduced to keep the version of ORM code and the snapshot name in sync somehow ( after all, this snapshot is kept only in PonyORM editor )
The situation is getting worse if we take into account different branches of the project. For example, we need to provide a hot-fix in some old branch by changing some aspect of the model, and would like to re-generate the ORM code - which design model snapshot should we use? Should we reflect the branch name and revision in the name of the snapshot? Seems unnecessarily complicated.
Alexander
We use the design model for maintaining our ERD, and generating the ORM code. Basically, the design model is, kind of, the ground truth for us.
The generated ORM code is stored in the project's source control. So we would like to store the design model there as well, so that both could be synchronized.
We know that snapshots can be created in the editor, but this means that extra effort needs to be introduced to keep the version of ORM code and the snapshot name in sync somehow ( after all, this snapshot is kept only in PonyORM editor )
The situation is getting worse if we take into account different branches of the project. For example, we need to provide a hot-fix in some old branch by changing some aspect of the model, and would like to re-generate the ORM code - which design model snapshot should we use? Should we reflect the branch name and revision in the name of the snapshot? Seems unnecessarily complicated.
Thanks for the explanation, now I understand what you mean. Some time ago, we had already started working on this feature, but then paused our progress. Hope we can resume it. By the way, what DBMS do you use?
Vlad
Lucky