Anonymous
@akozlovsky Actually, I'm still getting the same error message with volatile=True on the field as you suggested. Do you know what might be the matter? I thought volatile=True would prevent Pony from raising an Exception if a value has changed
Anonymous
https://gist.github.com/chrisshroba/2d3ccdd9f8fe7f066ad57765a29962d0
Anonymous
If you don't have time to look at this, I completely understand!
Alexander
Hi Chris! Thank you for reporting, I reproduced the error. This is a bug and I plan to fix it in a few hours
Anonymous
Thanks so much! I really appreciate that
Alexander
Volatile attribute should work as expected now: https://github.com/ponyorm/pony/commit/0cefc93323eaf9b2aedcadc23179f06ecf0e70fe
Elmcrest
hey all ... the python weekly newsletter just teached me that ponyorm exists. so I'm curious - why did you start it?
Elmcrest
I mean there is already djangoORM and SQLAlchemy (and probably some others, right?)
Elmcrest
I guess I skim through the docs first :D
Romet
sqlalchemy is bad and djangoORM is too django-oriented :)
Elmcrest
hehe ok
Romet
that's just why i'm here anyway, not sure why they created it :D
Elmcrest
I am wondering if it's possible to replace djangoORM ... probably not I'd say
Alyson
Romet why do you think SQLalchemy is bad?
Romet
it's a PITA to use, has a poor API
Elmcrest
what does Automatic query optimization actually do?
Elmcrest
like prefetching f.e. in django?
Alyson
I was just curious about the reason. I had a look at SQLalchemy and peewee, but right now I don't have a favorite ORM
Alexander
Hi Marius. The work on PonyORM (as a hobby project) was started long time ago, before Django and SQLAlchemy were announced. The internal architecture of Pony differs considerably from both Django and SQLAlchemy. Django uses ActiveRecord pattern, while PonyORM uses IdentityMap pattern. SQLAlchemy is too SQL-oriented, while Pony (at least theoretically) can be extended to support NoSQL databases as well. Automatic query optimization at this point means to things: 1) like prefetching in Django, but without necessity to specify it explicitly. It may be more efficient if a programmer underuse of overuse explicit prefetching. 2) Pony transforms some queries to a more efficient form, like subquery -> group by + left join
Elmcrest
oh, it's that old ... didn't expect that
Alexander
Pewee has a simpler architecture, and if you plan to extend existing ORM capabilities it may be easier with Pewee. But Pony allows much more complex queries
Romet
@abg99 in the agency I work at we use Django primarily, but some of my coworkers are doing contract work for a large telecoms company. Every single day they complain about something about SQLalchemy and I've seen how inconvenient it is to use compared to Pony and Django ORM.
Romet
And as Alexander said, it's primarily SQL-focused, which is bad :)
Alexander
In SQLAlchemy you basically write in SQL, but use some peculiar Python dialect of it. You need to understand what SQL text you are want to get. With Pony you can concentrate on logical meaning of a query and Pony will translate it to appropriate SQL. So, in my opinion, Pony queries are more high-level
Alyson
@amPerl @akozlovsky thank you for the answers. Have you guys use Pony with flask?
Alexander
Yes, in our current project fineartbiblio.com we use Pony, ReactJS, flask & PostgreSQL
Rozen
Pony ❤️
Alyson
Nice to see a project with those technologies. I will have a look at Pony and try to use it on something. Does it have a flask library?
Alexander
It may be used with flask easily, but doesn't have some special flask plugin yet
Lucky
Motorcycle rear ends a car on the highway http://redd.it/5fx5dd by @r_unexpected
Lucky
Oh, sorry wrong chat
Lucky
@amPerl @akozlovsky thank you for the answers. Have you guys use Pony with flask?
Am using it too, with flask and teleflask, to create Telegram Bots
Alyson
Am using it too, with flask and teleflask, to create Telegram Bots
Nice. I also want to create a telegram bot. Is it hard to get started? I want to create a bot with beautiful soup.
Alyson
It may be used with flask easily, but doesn't have some special flask plugin yet
Thank you for the answers! I am gonna try it as soon as possible
Alexey
Lucky
Nice. I also want to create a telegram bot. Is it hard to get started? I want to create a bot with beautiful soup.
Not that hard. The lib I made is open source, pytgbot https://github.com/luckydonald/pytgbot
Lucky
If you need help with that I can help you directly at https://telegram.me/pytg_group
Lucky
Oh my, so much link spam. Sorry.
Alyson
No problem. You will have a look at those links.
Lucky
Will there be a way to set Required(int, size=64, unsigned=False) in the online editor? I always have to edit the file after generating.
Lucky
What is the way to remove a row, I already have stored in a variable?
Lucky
What is the way to remove a row, I already have stored in a variable?
I got a State in the state variable (line 84) I found https://docs.ponyorm.com/api_reference.html?highlight=delete#delete Can I give that delete function a state instance (line 86)? A simple (but pythonic) del probably won't work (line 85)?
Lucky
Trying to get a state machine for my telegram bot implemented in Pony.
Lucky
Will there be a way to set Required(int, size=64, unsigned=False) in the online editor? I always have to edit the file after generating.
In my case It would be enough to be able to specify some **kwargs manually. Don't know If you want to add a field for signed and size, as it might become lengthy. On the other hand, that editor is a good play-arround or WYSIWYG alternative for the documentation.
Lucky
Simpler to understand example of my question
Romet
can't you do user.delete()?
Lucky
Thats possible?
Romet
https://docs.ponyorm.com/api_reference.html#Entity.delete
Romet
seems like it anyway
Alexander
Hi @luckydonald! In my understanding, a state is not an independent object, it is a property of some other object (like a chat, a message, a user, etc). Hence, it is better to model state just as an int attribute of another entity. Then, instead of deleting state, you just set it to appropriate int value. If you want to delete object (like a chat, a message, etc.) itself, you can call chat.delete()
Lucky
Thank you very much for your thoughts, they are very wise.
Lucky
In my case however I need to map massages to this state. In my telegram bot, where you can tag stickers with text this is the flow I want to archive: 1. User sends/forwards sticker to the bot @StickerTagBot. 2. Bot: "Send more stickers, or type something to tag them" 3a. User sends sticker -> 1 again 3b. User sends text -> 4 4. user sends text. bot stores text for all sent stickers
Alexander
Ok, in that case you probably can create addiional State object, which is linked to unprocessed stickers, etc. But maybe this is an overkill. I'd start with a simpler approach. There is a Chat object, which state may be 'ADDING_STICKERS', and there is a message object, which state may be 'UNPROCESSED_STICKER'. Then we have a function which process the chat state: def process_chat_state(chat, new_message): if chat.state == ADDING_STICKERS: if new_message.state == UNPROCESSED_TEXT: tag_name = new_message.text unprocessed_stickers = chat.messages.filter(message: message.state == UNPROCESSED_STICKER) for msg in unprocessed_stickers: add_tag(msg, tag_name) msg.state = PROCESSED chat.state = IDLE else: if is_sticker(new_message): new_message.state = UNPROCESSED_STICKER As I don't know Telegram API, the code above is just a wild guess, but I think something like that should work
Lucky
Huh. Interessting. I'm gonna give it a thought. Thanks!
Serg
Всем привет! Можете подскзать Pony ORM работает с asyncio? Интересно использовать c aiohttp
Alexander
Good day! This chat is in English. It is possible to use Pony ORM in async context, but at this moment all Pony ORM interactions with the database are synchronous. We plan to make asyncio support in the future, but other tasks (like adding migrations) are more important now
Serg
Good thing in pony orm that here not so hard to add async support unlike sqlalchemy
Alexander
I think it may looks as result = yield select(x for x in MyEntity)
Serg
And about migrations, when do you planning to release some beta version?
Alexander
I think we need two weeks to finish beta version
Serg
Oh, it's cool. Thank you for answers. I will go through pony orm tutorial, it's seems very perspective system :)
Serge
Surprisingly there is no point in asyncio db driver at all.
Serge
You can't do better than using thread pool for that behind the async calls
Serge
Your database still performs queries synchronously
Serg
So what a point of async drivers? For example https://github.com/aio-libs/aiopg
Romet
There very much is point to it
Romet
Otherwise things like pgbouncer would not exist
Anton
Hi! I created a small example of PonyORM query in aiohttp handler. To run a query in a separate thread I used threadpool from https://github.com/agronholm/asyncio_extras. It is very handy. https://gist.github.com/grudko/4c1dcd2a2eb29bc3d98cd19bfd916cbd
Serg
Wow, nice. Thank you!
Serge
Otherwise things like pgbouncer would not exist
that is not the part async driver is somehow care about. You still need thread pool in a Python driver
Serge
there is nice post here http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/
Serge
this is also helpful http://stackoverflow.com/a/16503103/396862
Angel
Can The Pony replace sqlalchemy no regrets?
Alexander
It depends on what you do with an ORM. SQLAlchemy has some features that Pony missing at this moment. The most obvious is migrations. We are working on migrations right now, and I hope we can release it in a few weeks. The other features includes recursive CTE queries and sharding. If you actively use these features, at this moment you may prefer to stay with SQLAlchemy. But in general I think PonyORM provides a better query syntax which allow expressing buisness logic of an application in a more readable form.
Angel
What do you mean by support to recursive CTE queries and sharding ? Does SQLAlchemy support those? Can the ponny support CTE it through raw queries?
Angel
whats the dev language of Entity-Relationship diagram editor?