
Paul
15.05.2017
06:45:56
If you use MySQL, Postgres, or Oracle, I'm pretty sure the db server will keep a log of the actual SQL statements that are executed, so you could see how your virtual attributes translate in the db access statements
Maybe Pony even does that for you in some debug mode - I am still fairly new to using Pony
If Pony doesn't offer that, it would be a nice feature for debugging

Janis
15.05.2017
06:48:40
Logging incoming queries inside my mySQL server isn't that hard :)

Google

Paul
15.05.2017
06:51:11
Since I am lazy by nature, I would like Pony to have that capability so that I can use it from my client code, regardless of database backend
I need to turn in, almost 2am for me and work starts early tomorrow - nice talking with you

Luckydonald
15.05.2017
08:12:33
Having this simplified relationship, I have a on-update trigger on Sticker which updates the .modified column on the database.
I now realized, that won't be executed if I add/edit tags to a sticker.
StickerTag(sticker=Sticker[123], text="some new tag")
What would be the best way to change the modified date?
Would be a on-update trigger on the StickerTag table, which updates the Sticker.modified, be a good idea?
I wan't to avoid doing it manually in application code, as I fear that I forget setting it somewhere.
Background is, that the modification timestamp is needed for syncing updated items to the elasticsearch index.


Alexander
15.05.2017
10:34:33
Yes, I think trigger on StickerTag table which updates modified column of the Sticker table is a good idea. You probably need two triggers - one ON INSERT, UPDATE and another ON DELETE


Luckydonald
15.05.2017
19:03:08
Thanks :D
Yes, I think trigger on StickerTag table which updates modified column of the Sticker table is a good idea. You probably need two triggers - one ON INSERT, UPDATE and another ON DELETE
For reference, here are my triggers:
db.execute(
"CREATE OR REPLACE FUNCTION update_tag__sticker_modified_column() "
"RETURNS TRIGGER AS $$ "
"BEGIN "
" IF (TG_OP = 'UPDATE') OR (TG_OP = 'INSERT') THEN "
" IF NEW.sticker IS NOT NULL THEN "
" UPDATE sticker SET modified = now() WHERE file_id=NEW.sticker; "
" END IF; "
" RETURN NEW; "
" ELSIF (TG_OP = 'DELETE') THEN "
" IF OLD.sticker IS NOT NULL THEN "
" UPDATE sticker SET modified = now() WHERE file_id=OLD.sticker; "
" END IF; "
" RETURN OLD; "
" END IF; "
" RETURN NULL; " # result is ignored since this is an AFTER trigger
"END; "
"$$ LANGUAGE 'plpgsql';".replace("$$", "$$$$"), dict())
db.execute(
"DROP TRIGGER IF EXISTS update_sticker__tag_insert ON tag;", dict())
db.execute(
"DROP TRIGGER IF EXISTS update_sticker__tag_update ON tag;", dict())
db.execute(
"DROP TRIGGER IF EXISTS update_sticker__tag_delete ON tag;", dict())
db.execute(
"CREATE TRIGGER update_sticker__tag_insert AFTER INSERT ON tag "
"FOR EACH ROW EXECUTE PROCEDURE update_tag__sticker_modified_column();", dict())
db.execute(
"CREATE TRIGGER update_sticker__tag_update AFTER UPDATE ON tag "
"FOR EACH ROW EXECUTE PROCEDURE update_tag__sticker_modified_column();", dict())
db.execute(
"CREATE TRIGGER update_sticker__tag_delete AFTER DELETE ON tag "
"FOR EACH ROW EXECUTE PROCEDURE update_tag__sticker_modified_column();", dict())
orm.commit()
Any Idea what I rights do I have to set to solve
Error: must be owner of function update_tag__sticker_modified_column
(First db.execute)


Alexander
15.05.2017
21:57:24
I think the function was created under another database user previously (maybe root), and current user has no right to replace it

Luckydonald
15.05.2017
22:11:54
Deleting it the 3rd time helped, indeed.
Thanks

Paul
15.05.2017
22:20:16
@luckydonald - I think your tip re orm.sql_debug is just what I was looking for, I'll give it a try next time I'm in Ponyworld

Google

Luckydonald
15.05.2017
22:23:37
Great to help back.
What could be a reason for
pony.orm.dbapiprovider.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
?
I have postgres (9.5.0) running on localhost.
db.bind("postgres", user='postgres', password='', host='localhost', database='postgres')
The first table got created.

Alexander
16.05.2017
10:30:24
From my understanding there may be many reasons
http://stackoverflow.com/questions/15934364/psql-server-closed-the-connection-unexepectedly

Luckydonald
16.05.2017
18:47:38
It was a error with pg_hba.conf and somehow the port being occupied by something else.
I think
pony.orm.dbapiprovider.ProgrammingError: column "user" does not exist
should also tell you the table.

Alexey
16.05.2017
18:49:06

Luckydonald
16.05.2017
18:51:28
Would adding content be possible anyway?
I even searched the logs.
I could think of two ways:
Add metadata to the exception (e.g. table="Fooo")
Adding logging (e.g. logger.debug("Creating mapping for table {table!r}".format(table="Foo"))
This would probably be in DBObject
Is there somewhere a place to discuss how migrations will work?

Alexander
16.05.2017
19:26:35
Right here, or you can message me directly

Luckydonald
16.05.2017
19:29:39
I think here is better for everyone.

Richie
17.05.2017
02:49:19
Is it okay for me to sell my apps using Pony ORM as the database?
Can I develop modules to improve Pony ORM as well? I see this ORM is raisingly

Alexey
17.05.2017
03:08:08

Richie
17.05.2017
03:31:21
I still don't have an idea of it
Is there any big company use Pony ORM already?
I look into Pony ORM syntax is Pythonic

Alexey
17.05.2017
03:44:38

Google

Alexey
17.05.2017
03:52:16
Is there any big company use Pony ORM already?
Big companies that bought licenses, before we released under Apache 2.0, were Cisco and PremiumBeat. Also Ideco uses it. Think now more companies use it, after we released Pony under Apache.
Also we can see that a number of companies and tech universities use the Editor. One of them is SAP.

Richie
17.05.2017
03:56:25
wow, nice to hear that..Changing the licensed is a good decision.
Now I don't have to worry about license legality to deploy my apps. I intend to help Pony ORM developments once my apps is going to be used widely by my clients.

Alexey
17.05.2017
04:07:45
Can you share what kind of app is that?
Or the site name?

Richie
17.05.2017
04:18:32
We try to make systems in the hospitals based on web but with no Frameworks (less).
We still develop it ,almost reach about 40% until it will works .we Haven't decide the database which are going to be used .
I believe ORM method would be just fine and Pony ORM is one of my preferred suggestions

Alexey
17.05.2017
04:26:32
Do you consider using AWS?

Richie
17.05.2017
04:26:43
Whats a AWS?

Alexey
17.05.2017
04:26:55
Amazon Web Services

Richie
17.05.2017
04:27:24
This is one of my projects https://www.korbanaqiqah.com
It use Django Framework and MySQl as the database..But I plan to convert it to just use other ORM than Django ORM
I know it s hard to get other ORM will works in Django..so Now ,we are trying to not using Django anymore for our next projects

Alexey
17.05.2017
05:09:06

Luckydonald
17.05.2017
09:03:03

Google

Luckydonald
17.05.2017
09:04:39
Huh, 99 members.
Lemme change that :D
@funkyKay I talked about PonyORM earlier.
(The people in this chat also know SQL way better than me, lol)

Richie
17.05.2017
09:14:29

Luckydonald
17.05.2017
09:29:33

Paul
17.05.2017
09:51:20
How active is Pony development? The GitHub repo doesn't show any activity in a while

Richie
17.05.2017
09:52:40

Paul
17.05.2017
10:01:49

Alexander
17.05.2017
10:07:16
Recently the activity was stalled because we are working on another projects which has some deadlines. As Pony is free we cannot work on it full time. But we believe Pony has a great potential. In the near future we plan to return to more active work on Pony. We have some internal branches which needs to be merged properly before we can push them to GitHub. I hope we can do it soon.

Bruno
17.05.2017
10:08:26
Hello,
Does Pony support the equivalent of an array of strings for an attribute?

Paul
17.05.2017
10:11:42

Alexander
17.05.2017
10:12:00
The internal brunches which need to be finish include: migrations, support of MS SQL Server, support of entity methods which can be used inside queries, better integration with JavaScript, full test suite which covers all databases and not only SQLite, refactoring of Pony code to make it more readable to external developers, etc.

Paul
17.05.2017
10:14:24
Is there a way to export the model itself to JSON?

Bruno
17.05.2017
10:15:27
Thanks.
Also, can we attach validation functions to the fields?

Henri
17.05.2017
10:20:23

Richie
17.05.2017
10:23:23
Neverheard. Is it new?

Alexander
17.05.2017
10:24:17

Google

Henri
17.05.2017
10:32:45
Neverheard. Is it new?
Not really. It exists already for some years and the author Martijn Faassen was also the initiator of the Grok framework and many years core developer in zope.
But Morepath is quite different, much cleaner and has some really powerful paradigms.
http://morepath.readthedocs.io

Richie
17.05.2017
10:41:32
ah .. I see
what does it specific used for?
I need to work now..thanks for sharing the information

Bruno
17.05.2017
10:46:22
I'm quite fond of HUG: https://github.com/timothycrosley/hug
Sparse docs unfortunately.

Henri
17.05.2017
10:48:04
First it was mainly intended for REST frameworks to play together with SPAs. But now it also integrates some template systems and is quite universal.
It's also very extensible and modular.
For a quick overview look at http://morepath.readthedocs.io/en/latest/#morepath-super-powers

Bruno
19.05.2017
09:59:25
- Does Pony have a get_or_create entity classmethod?
- Also, is it possible to have an abstract class that one can inherit from, which still has methods of db.Entity but does not become a table when create_mapping is called?

Alexander
19.05.2017
10:02:25
> Does Pony have a get_or_create entity classmethod?
MyEntity.get(**kwargs) or MyEntity.create(**kwargs)
> Also, is it possible to have an abstract class
Can you explain in more details how you would use it?

Bruno
19.05.2017
10:07:01
For example I'd write a convenience get_or_create function with transaction on the abstract class Base. Then all the actual models inheriting could call this. Similarly with having a timestamp attribute which auto adds on creation.

Alexander
19.05.2017
10:10:54
You can write a mixin with common methods:
class MyMixin(object):
def my_method(self):
...
class MyEntity(MyMixin, db.Entity):
...
But at this moment you need to include timestamp attribute separately to each entity:
created_at = Required(datetime, default=datetime.now)

Bruno
19.05.2017
10:12:56
OK. Thank you for the prompt response.
My problem with the mixin approach was that I wouldn't have access to the class in the method, so I couldn't write cls.get(**kwargs), cls.create(**kwargs) etc.

Святослав
19.05.2017
10:19:06
If you want use object from get_or_create helper, whole code that use it should be wrapped by db_session. Or you should get object again by id.
@akozlovsky right?

Alexander
19.05.2017
10:20:37
If you want to write method like get_or_create it is better to define it as @classmethod so it will receive cls instead of self as first argument