
Bruno
19.05.2017
10:23:47
Actually I find that I can't use inheritance at all to transfer attributes, even if the previous model inherits from db.Entity.
Is this correct?

Alexander
19.05.2017
10:26:22
What do you mean by "transfer attributes"?

Bruno
19.05.2017
10:34:16
class A(db.Entity):
foo=Required(str)
class B(A):
bar=Required(str)I'd expect to have tables A and B, with B supporting foo and bar. I thought your comment about repeating the timestamp field only applied to models inheriting from a non-db.Entity class.

Google

Alexander
19.05.2017
10:43:08
There are several ways to implement inheritance in the database:
1) Each entity class & subclass maps to separate table
2) Each subclass maps to the same table as a parent class
Django uses the first approach, and Pony uses the second one. Each of this approaches has benefits and drawbacks. The first way require SQL join to correctly retrieve an object from the database. The second way creates columns which contains NULL for objects which belong to other subclasses. In general, using single table for base class and subclasses is more efficient, because it does not requre SQL joins, which are slow.
Why do you want to use separate tables for A and B classes?

Bruno
19.05.2017
10:45:23
Understood sorry I just noticed that passage in the docs.

Maxim
24.05.2017
11:47:53
Guys, hi. Who knows how: 1) Set db_session at once for all queires (for ex. flask) 2) What is about models inheritance.. Will it work without problem with metaclasses or db connection...?

Alexander
24.05.2017
12:52:10
Hi Maxim!
Regarding the first question, you can do the following:
@app.before_request
def enter_db_session():
orm.db_session.__enter__()
@app.teardown_request
def exit_db_session(exc):
orm.db_session.__exit__(exc and type(exc), exc)
I don't fully understand the second question, I think it should work without any problems

Maxim
24.05.2017
13:03:29
thanks, .... I also wanted to do this trick... but when i saw dbsession class i not know what method work perfectly with it...
Second, is for ex .. We have some models... (db.Entity) and fields.... class A(db.Entity): class B(A): ... override somes method or fileds... It will work?

Alexander
24.05.2017
13:11:00
When one entity inherits from another one, they share the same table. You cannot override fields, but you can add some methods. If yo want to have some common methods for unrelated entities, you can define them in mixin and inherit from that mixin too. If you want to override previously defined method, you need to specify mixin first.
class MyMixin(object):
def __str__(self):
...
class MyEntity(MyMixin, db.Entity):
...

Maxim
24.05.2017
13:14:27
I ask.. because when i used peewee .. i had problem with model inheritance... Solutions for it i did not find...It worked but with dirty code style...
Hm... The table is model field? What's if i will use different table via class fields.. ? 3) SQLServer support? Is it work?

Alexander
24.05.2017
13:21:24
1) In Pony, if one entity inherits from another, they share the same table, you cannot override that. For different unrelated entities you can specify _table_ explicitly for each entity
2) SQLServer support is work in progress.

Maxim
24.05.2017
13:25:44
Hm... no? class A:
_table = 'asasas'
class B(A):
_table = 'sdsd'
print(B()._table)
>sdsd

Alexander
24.05.2017
13:32:57
It will not work. There are several strategies how class inheitance can be mapped to database tables. One way (used in Django) is to have separate table for each class. Another way (used in Pony) is to map all classes inherited from the same entity to a single table, and have optional columns for each inherited class. The first way is not as efficient, beause in order to retrieve an object from the database it requires join of several tables, which is slow operation. In the future we can add first type of inheritance to Pony in order to provide compatibility with Django, but right now it support single-table inheritance

Google

Maxim
24.05.2017
13:41:11
Alexander, Thanks a lot for all. You are the first of communicative guys in this chat ... Where are the others? ?

stsouko
25.05.2017
06:24:08

Rozen
25.05.2017
06:24:53
Lord of the Pony

Artur Rakhmatulin
25.05.2017
08:13:54

Luckydonald
25.05.2017
09:43:02
I am just here to watch pony.
Using pony with postgres, setting size of an id field to 64 changes referencing values from INTEGER to BIGINT but not the fields auto increment SERIAL to BIGSERIAL.
Is that intentional, an error just in the editor, or in the ORM as well?

Alexey
26.05.2017
18:42:55
agreed, should be BIGSERIAL
it is Pony bug too

Luckydonald
26.05.2017
18:55:43
There's also smallserial
https://www.postgresql.org/docs/9.6/static/datatype-numeric.html

Alexey
26.05.2017
18:56:00
ok, thanks

Luckydonald
26.05.2017
19:56:26
How do I ensure my 6+ minutes query does not time out?
Has pony a limit there?
db.execute('UPDATE "stickermessage" AS "sm" SET "new_sticker" = (SELECT "id" FROM "sticker" WHERE "file_id" = sm."sticker")', dict()

Alexander
26.05.2017
19:57:40
Pony iself does not set any limits for query execution

Alberto
29.05.2017
23:16:14
Hi everyone!
Just a question regarding pony
Is there a way to create a pandas DataFrame by reading directly a pony select( ) object?
Or, alternatively, what would be a good indirect way to do so?

Alexey
29.05.2017
23:23:10
hey Alberto
currently the best way is to use the to_dict method of an entity https://docs.ponyorm.com/api_reference.html?highlight=to_dict#Entity.to_dict
here you can find an example https://github.com/ponyorm/pony/issues/72

Alberto
29.05.2017
23:39:42
Thanks a lot! to_dict was what I needed
I created a dictionary for every object in the selection and then joined them in a DataFrame in the way explained here:
https://stackoverflow.com/questions/17751626/create-a-pandas-dataframe-from-multiple-dicts

Google

Alexey
29.05.2017
23:41:12

Alberto
31.05.2017
05:24:58
Hi again! I have another question. I'm trying to convert a Python project to a Windows executable file, using PyInstaller. It generates the executable, but when I try to run it, an error occurs, related to pony. The error is:
" ImportError: No module named 'pony.orm.dbproviders' "
Is there a way to avoid that error? Should I use another tool, like Py2exe, to create the exe file? I have the whole traceback of the error, in case it helps. Thanks in advance for any help you can provide!!

Luckydonald
31.05.2017
06:35:48
Check if there are any files describing the dependencies to include in the Exe?
Maybe pony is missing there

stsouko
31.05.2017
07:12:24
Read about hooks
https://pythonhosted.org/PyInstaller/hooks.html

Alberto
31.05.2017
14:53:28
Thanks for the advice! I'll look into that

az
04.06.2017
06:24:02
hello
if I need to use ponyorm entities from several python modules, I need to import these entities in every module, do I understand this correctly?

Luckydonald
04.06.2017
06:38:58
Yeah

az
04.06.2017
06:39:51
and do I need to use db.bind inside each of these modules?

Henri
04.06.2017
06:44:05
bind and mapping you use only once.

az
04.06.2017
06:46:12
can I generate mappings inside a function?
I have a code similar to:
from . import models
def init_db(db):
db.generate_mapping(create_tables=True)
and mappings are not generated
looks like I'm only able to use the orm if it is defined at the global context, is there a way to somehow pass context between functions?

Luckydonald
04.06.2017
07:05:21
It should be possible

Matthew
06.06.2017
20:09:54
Hey, big pony user, just noticed there's a telegram group :)

Alexey
06.06.2017
21:16:52

Luckydonald
07.06.2017
06:13:59

Google

Matthew
07.06.2017
09:39:33
Are the main authors planning future development on pony's core?

Alexander
07.06.2017
09:43:22
Yes, we are. We need to finish migrations first, because it blocks other tasks.

Matthew
07.06.2017
09:43:32
Great to hear :)
Is the migrations work in progress currently public?

Alexander
07.06.2017
09:48:14
No, but I hope to release it soon. The problem with migrations is that we need to change previous tables to make it compatible with migrations. This requires upgrade of previous tables. After such upgrade it is not possible to use previous version of Pony. So we need to be sure that everything is good

Matthew
07.06.2017
09:48:47
I'm happy to help test this, I have a few projects with reasonably complex pony-created tables.
Not on my live database of course

Alexander
07.06.2017
09:50:38
Good to hear. Give me few days, and I'll release migrations branch to public

Henri
07.06.2017
09:51:20
?

Z.
07.06.2017
11:52:21
Hey Alexander, I guess you are getting a lot on this, using MySQL enums with Pony.
I have followed this tutorial: https://mailman-mail5.webfaction.com/pipermail/ponyorm-list/2014-September/000125.html
And ended up with this code: https://paste.ofcode.org/Ed2jS3t2pHNeUSdRznuc6R
Getting this error: TypeError: Expression UserGroup.Regular has unsupported type 'UserGroup'
It happens in extract_vars inside core.py and it probably fails within get_normalized_type_of(UserGroup.Regular).
Can you suggest something?

Alexander
07.06.2017
21:54:34
Hi @dereli, I ran your example but encounter some other problems as well. I'll try to analyze it and will answer tomorrow

Z.
08.06.2017
08:15:40
@akozlovsky, the other problems on my code or some other unexpected issues with Pony? Thanks btw.

Luckydonald
08.06.2017
08:32:03
I thought it would still be in planing phase.
That's why I later crated github.com/luckydonald/pony_up

Alexander
08.06.2017
08:37:55
Wow, that's interesting, we will look into it

Z.
08.06.2017
08:43:53
They were never invoked for me, so I couldn't make sure they're correct. If I can be of any help on that please advise.

Luckydonald
08.06.2017
08:44:11

Google

Matthew
08.06.2017
08:45:13

Alexander
08.06.2017
08:48:14

Matthew
08.06.2017
08:48:54
if there is the explicity casting to a list with [? wont that stop an SQL LIMIT being included?
[ : ]

Luckydonald
08.06.2017
08:49:18

Z.
08.06.2017
08:50:12

Matthew
08.06.2017
08:50:22
:)

Alexander
08.06.2017
08:53:03

Luckydonald
08.06.2017
08:53:58

Alexander
08.06.2017
08:55:53

Matthew
08.06.2017
08:56:40
ah yes, good point, like [ :1 ][ 0 ]