@ponyorm

Страница 8 из 75
Chris
30.11.2016
20:17:06
Thanks so much! I really appreciate that

Alexander
01.12.2016
04:25:34
Volatile attribute should work as expected now: https://github.com/ponyorm/pony/commit/0cefc93323eaf9b2aedcadc23179f06ecf0e70fe

Marius
01.12.2016
16:11:06
hey all ... the python weekly newsletter just teached me that ponyorm exists. so I'm curious - why did you start it?

I mean there is already djangoORM and SQLAlchemy (and probably some others, right?)

Google
Marius
01.12.2016
16:12:32
I guess I skim through the docs first :D

Romet
01.12.2016
16:14:04
sqlalchemy is bad and djangoORM is too django-oriented :)

Marius
01.12.2016
16:14:30
hehe ok

Romet
01.12.2016
16:14:41
that's just why i'm here anyway, not sure why they created it :D

Marius
01.12.2016
16:14:50
I am wondering if it's possible to replace djangoORM ... probably not I'd say

Alyson
01.12.2016
16:15:02
Romet why do you think SQLalchemy is bad?

Romet
01.12.2016
16:15:25
it's a PITA to use, has a poor API

Marius
01.12.2016
16:17:19
what does Automatic query optimization actually do?

like prefetching f.e. in django?

Alyson
01.12.2016
16:18:18
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
01.12.2016
16:21:12
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

Marius
01.12.2016
16:22:08
oh, it's that old ... didn't expect that

Alexander
01.12.2016
16:22:26
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

Google
Romet
01.12.2016
16:23:11
@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.

And as Alexander said, it's primarily SQL-focused, which is bad :)

Alexander
01.12.2016
16:24:29
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
01.12.2016
16:27:28
@amPerl @akozlovsky thank you for the answers. Have you guys use Pony with flask?

Alexander
01.12.2016
16:28:23
Yes, in our current project fineartbiblio.com we use Pony, ReactJS, flask & PostgreSQL

Rozen
01.12.2016
16:29:44
Pony ❤️

Alyson
01.12.2016
16:34:00
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
01.12.2016
16:35:56
It may be used with flask easily, but doesn't have some special flask plugin yet

Luckydonald
01.12.2016
16:36:58
Oh, sorry wrong chat

@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
01.12.2016
16:39:35
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.

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

Luckydonald
01.12.2016
16:43:50
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

If you need help with that I can help you directly at https://telegram.me/pytg_group

Oh my, so much link spam. Sorry.

Alyson
01.12.2016
16:46:34
No problem. You will have a look at those links.

Luckydonald
02.12.2016
08:18:32
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.

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)?

Trying to get a state machine for my telegram bot implemented in Pony.

Google
Luckydonald
02.12.2016
08:41:30
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.

Romet
02.12.2016
08:53:51
can't you do user.delete()?

Luckydonald
02.12.2016
08:56:41
Thats possible?

Romet
02.12.2016
08:56:52
https://docs.ponyorm.com/api_reference.html#Entity.delete

seems like it anyway

Alexander
02.12.2016
08:59:13
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()

Luckydonald
02.12.2016
09:00:51
Thank you very much for your thoughts, they are very wise.

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
02.12.2016
09:26:39
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

Luckydonald
02.12.2016
09:31:12
Huh. Interessting. I'm gonna give it a thought. Thanks!

Serhii
02.12.2016
11:46:07
Всем привет! Можете подскзать Pony ORM работает с asyncio? Интересно использовать c aiohttp

Alexander
02.12.2016
11:48:26
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

Serhii
02.12.2016
11:50:23
Good thing in pony orm that here not so hard to add async support unlike sqlalchemy

Alexander
02.12.2016
11:51:18
I think it may looks as result = yield select(x for x in MyEntity)

Serhii
02.12.2016
11:52:00
And about migrations, when do you planning to release some beta version?

Alexander
02.12.2016
11:53:16
I think we need two weeks to finish beta version

Serhii
02.12.2016
11:55:19
Oh, it's cool. Thank you for answers. I will go through pony orm tutorial, it's seems very perspective system :)

Serge
02.12.2016
12:58:20
Surprisingly there is no point in asyncio db driver at all.

You can't do better than using thread pool for that behind the async calls

Google
Serge
02.12.2016
13:00:47
Your database still performs queries synchronously

Serhii
02.12.2016
13:01:21
So what a point of async drivers? For example https://github.com/aio-libs/aiopg

Romet
02.12.2016
13:20:55
There very much is point to it

Otherwise things like pgbouncer would not exist

Anton
02.12.2016
13:24:38
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

Serhii
02.12.2016
13:30:13
Wow, nice. Thank you!

Serge
02.12.2016
13:32:16
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

there is nice post here http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/

this is also helpful http://stackoverflow.com/a/16503103/396862

Angel
02.12.2016
14:54:07
Can The Pony replace sqlalchemy no regrets?

Alexander
02.12.2016
15:52:32
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
02.12.2016
15:57:58
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?

whats the dev language of Entity-Relationship diagram editor?

Alexander
02.12.2016
16:02:37
By CTE queries I mean this: http://stackoverflow.com/questions/25896706/recursive-cte-query I think you can use them in Pony using raw queries

The graphical part of diagram editor uses JavaScript, the code generation part uses Python

Angel
02.12.2016
16:03:45
Congrats! It looks awesome!

plain js?

Alexander
02.12.2016
16:05:43
Curently it uses KnockoutJS for templates and Raphael for SVG generation. Right now we rewriting it in ReactJS+Redux+FlowType

Luckydonald
02.12.2016
16:43:54
Can I fairly easily add that missing field myself?

Alexander
02.12.2016
16:44:07
Sure. What database do you use?

Google
Luckydonald
02.12.2016
16:44:11
User has a id = PrimaryKey(int)

Angel
02.12.2016
16:44:34
This is first class customer service!

Luckydonald
02.12.2016
16:44:35
This is the schema: https://editor.ponyorm.com/user/luckydonald/Tags

This is first class customer service!
It really is. Thank you very much, btw.

Alexander
02.12.2016
16:45:33
alter table "stickermessage" add column "in_state" int references "user"("id");

Страница 8 из 75