Yehor
I got this exception when stopping/starting MySQL to test how Pony will be working
Yehor
Yehor
I am using flask class based views, not just functions
Jones
I create filter of Or's dynamically
query.filter(raw_sql(' OR '.join(list_ors)))
but expression not resolve when join foreing column "x.technical.name"
missing FROM-clause entry for table "technical"
LINE 4: AND (reference ILIKE '%M%' OR x.technical.name ILIKE '%M%'...
How I put join in clause to resolve expression or any another method.
Tks
Xavier
Anyone knows if ponyorm works with kivy on android?
Matthew
If I have a python list of pony objects, how can I filter by whether a Set contains any of the objects in the list?
Matthew
I’m sure I’ve done this before but I’ve forgotten it 🙂
Matthew
items = Set(Item)
Matthew
x.items (any matches) python_list of Items
Matthew
I tried any, but I don’t think it exists in pony?
Alexander
You can
exists(item for item in x.items if item in python_list)
Maybe there is something more compact, but I cannot look up right now
Matthew
Sorry, nevermind. I realised I actually only have one Item
Jones
Alexander
Hi, sorry for delay with the answer. Let me think a bit about it...
Alexander
For many-to-one relationship you can force adding join by adding some condition (which is not raw sql) which mentions this attribute:
q = select(x for x in MyEntity)
...
q = q.filter(lambda x: x.technical.id > 0)
...
q = q.filter(raw_sql(' OR '.join(list_ors)))
The condition x.technical.id > 0 is always true, but it forces adding this join
Matt
Well guys, I changed jobs and won’t work with PonyORM anymore, so I’ll leave the channel before long. Thanks for everyone’s help this year, awesome community!
Alexander
Goodbye Matt, and success to you with your new job!
Anonymous
Happy Independence Day everyone
Alexander
🎉🎉🎉
М
Hello everyone! I have a question: is it possible in PonyORM to create tables after you generated mapping, not in exact same time?
Alexander
Hi! Yes, you can call db.generate_mapping(create_tables=False), and later you can call db.create_tables() and db.drop_all_tables(with_all_data=True)
М
М
Alexander
You're correct, create_tables is False by default, so I mean check_tables=False
М
М
Hello again! Your ORM has an awesome syntax of applying number of filters dynamically to one query object:
q = select(...)
q = q.filter(...)
q = q.filter(...)
...
It joins filters with AND. Is there a way to do the same thing, but join them with OR?
I've seen there a guy, who used query.filter(raw_sql(' OR '.join(list_ors))) for such thing. Is it the only/best way of doing it?
М
Matthew
What’s the best way to copy a pony object, that has one to many and many to many relationships? I want to preserve everything except the primary key and another field which is a uuid
Matthew
Maybe using to_dict() ?
Christian
What's the state of migrations? I'm at a point again, where I could really use a feature that helps me easily change schemas.
Alexander
Hi Christian! Migrations are not released yet. I hope we can release it in a month. What database do you use?
Christian
MySQL - I've looked at the migrations branch on github, but it's about 6 months behind the orm branch?
Christian
I've read your comments on why it is difficult to implement - from the outside (and only recently following Pony) it seems like this is a big block that's holding up development?
Alexander
Recently the development was slow, because I had absolutely no time to work on Pony. Alexander Tischenko were working on a new version of migrations, with a good success, and I hope we can show it soon. The good news is that I should return to active developing of PonyORM soon. I have some big plans, but first we need to finish migrations...
Christian
Thanks for the update! I appreciate how active you are in maintaining this! 👍
Permalink Bot
Permalink Bot
Christian
Christian
Lucky
Lucky
I needed bigger changes for a project, and at some point couldn't wait with doing migrations.
Alb
Hi guys. Read the docs and didn't see any non blocking examples (i.e using async/await keywords). The only mention about async I saw is here https://docs.ponyorm.org/transactions.html#using-db-session-with-generator-functions-or-coroutines. Looks like Pony is sychronous ORM, right? Are you going to implement asyncronous functionalities in the future?
Alb
Sorry guys, my bad. Didn't read carefully
"The @db_session() decorator can be used with generator functions or coroutines too. The generator function is the function that contains the yield keyword inside it. The coroutine is a function which is defined using the async def or decorated with @asyncio.coroutine."
Alb
Will try coroutine
Alexander
Hi Alb! It turns out db_session doesn't work correctly with async code. Specifically, all coroutines will use the same database connection and hense use the same transaction, which is wrong. We need to add real async support for coroutines. Before this, you can use short synchronous db_session blocks inside async code, each db_session should end before coroutine freezes. Alas, it may be inconvenient, as you cannot use the same object in different db_sessions without make_proxy calls
Alb
thank you for clarification
Alb
@metaprogrammer do you have a roadmap or approx terms for adding async support?
Ghulam
hi, I have SQL Alchemy code that I need to convert to pony
software_id = Column(String(36))
software_version = Column(String(48))
@hybrid_property
def redirect_uris(self):
if self.redirect_uri:
return self.redirect_uri.splitlines()
return []
@redirect_uris.setter
def redirect_uris(self, value):
self.redirect_uri = '\n'.join(value)
how to do that setter decorator in pony?
Ghulam
Oh, never mind, i've figured it out.. 🙏
Lucky
Lucky
Are you a bot, or real user?
Lucky
Nah, you can just program a telegram client like the apps.
Lucky
So user-bot, not bot-bot.
Иван
Oh, i didn't know about it
@
Does Pony support Amazon Redshift?
Alexander
I haven't tried it, but I think it should, because the connection to Redshift goes through psycopg2 which is supported
М
Maybe you should use something like that: https://protectronbot.com/ ?
Alexander
We have some oopsie here. We have only two main admins and the creator's account was deleted. So we cant grant admin permissions.
Kaltenstein
Contact tgram support to have ownership reassigned.
Anonymous
^ Is there no way to delete spam like this from the group?
Иван
Anonymous
Hey guys, I have some strange issue: I have a table created as: CREATE TABLE "File" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, "name" TEXT NOT NULL, "description" TEXT NOT NULL, "icon" TEXT NOT NULL, "upload_date" DATE, "owner" INTEGER NOT NULL REFERENCES "Owner" ("id") ON DELETE CASCADE ) to store uploaded files in a webapp. When I try to add a file I get errors:
Anonymous
db.File(name=sf, description='en fil', owner=owner, icon='temp text') # => TypeError: Unknow attribute 'icon'
db.File(name=sf, description='en fil', owner=owner) # => pony.orm.core.TransactionIntegrityError: Object File[new:1] cannot be stored in the database. IntegrityError: NOT NULL constraint failed: File.icon
Anonymous
Anyone has any clue what could be wrong? Thanks!
Alexander
Can you show your File entity declaration?
Anonymous
@aerok : Ah, thanks. Your question solved it. Turned out I was using an old database created with an icon = Required(string), but in the current, that one was commented. So the first line about was an error from Pony, but the second one from SQLite. My bad, but perhaps the first error could clarify that the attritue icon is in the database but not in the declaration... or maybe that would be difficult to implement. Anyway, thanks.
Alexander
You're welcome. Best way to let us not to forget about this is to create an issue on Github. If it's okay for you.
dovaogedot
Can somebody please share a link where I can find out how to do migrations with pony?
Alexander
Migrations is not released yet, we are working on it
Alexander
Official migrations are not released yet, we are working on it.This week I return to active development of PonyORM, so the work will go faster. I really hope we can finish before the end of August
Drop
Alexander
Thanks, much appreciated!
David
David
М