@ponyorm

Страница 19 из 75
Luckydonald
18.01.2017
19:29:41
Doesn't work.

#issue On a sidenote, probably unrelated: cmd+A (select everything) doesn't work either.

It generates db.bind("postgres", host="", user="", password="", database="") Instead of db.bind("postgres", host="postgres", user="user", password="password", database="tags")

Alexey
18.01.2017
20:07:23
Google
Alexey
18.01.2017
20:07:43
fixed

Luckydonald
18.01.2017
22:58:46
If I set sql_default="NOW()" for a datetime column, do I have to set volatile=True?

Alexander
18.01.2017
23:04:50
Well, the default will be applied to insert only. But if you plqn to create object and to continue work with it in the same transaction, then probably yes

Luckydonald
19.01.2017
02:18:10
Okey.

ApiKey.exists(id=api_key) (id is type UUID) raises: File "/app/src/pony/pony/orm/dbapiprovider.py", line 726, in validate return UUID(hex=val) File "/usr/local/lib/python3.5/uuid.py", line 140, in __init__ raise ValueError('badly formed hexadecimal UUID string') ValueError: badly formed hexadecimal UUID string Shouldn't it just return False?

Can pony orm handle Enums in postgres? https://www.postgresql.org/docs/9.1/static/datatype-enum.html

Micaiah
19.01.2017
02:55:49
Can pony orm handle Enums in postgres? https://www.postgresql.org/docs/9.1/static/datatype-enum.html
Would they use Python enums? Because Python enums are.. interesting.

Luckydonald
19.01.2017
02:56:34
Ngalim
19.01.2017
11:52:24
hi, is there a problem with editor.ponyorm.com ?

Alexander
19.01.2017
11:53:03
I think it is up

If you manually change plural to 'Jobs', after that it should follow again

Ngalim
19.01.2017
11:55:29
thank you

Alexey
19.01.2017
14:57:01
should be fixed now

Google
stsouko
20.01.2017
11:28:53
Hello! class Molecule(db.Entity): _table_ = (schema, 'molecule') id = PrimaryKey(int, auto=True) children = Set('Molecule', reverse='parent', cascade_delete=True) parent = Optional('Molecule', reverse='children') merge_source = Set('Molecule', reverse='merge_target') # molecules where self is more correct merge_target = Set('Molecule', reverse='merge_source') # links to correct molecules how to set schema for many-to-many table?

I try to implement DB for storing chemical reactions and molecules with versioning of structure

Alexander
20.01.2017
11:31:00
You can specify 'table' option for any Set attribute of many-to-many relationship: merge_source = Set('Molecule', table=['schema_name', 'table_name'])

stsouko
20.01.2017
12:30:35
Thank you!

Alexey
20.01.2017
15:19:56
Still missing size=64 for ints, and sql_default='NOW()' for datetimes
Try now @luckydonald size for ints and sql_default options have been added

Luckydonald
22.01.2017
00:07:32
Yeah, working! Awesome!

And again forgot to log in before editing :/ Lets do it again :D

If I set sql_default="NOW()" will the datetime field be loaded after creation? Somehow how I imagine auto=True [0] to work. The volatile=True [1] allows the database to be changed outside of pony, but does it mean, this is less efficient, because it need to check that field every time I used it (read/write)? [0] https://docs.ponyorm.com/api_reference.html?highlight=size#cmdoption-arg-auto [1] https://docs.ponyorm.com/api_reference.html?highlight=size#cmdoption-arg-volatile

How do I put text[] type in ORM? http://www.monkeyandcrow.com/blog/tagging_with_active_record_and_postgres/ https://www.postgresql.org/docs/9.6/static/arrays.html

Alexander
22.01.2017
20:18:11
If I set sql_default="NOW()" will the datetime field be loaded after creation? Somehow how I imagine auto=True [0] to work. The volatile=True [1] allows the database to be changed outside of pony, but does it mean, this is less efficient, because it need to check that field every time I used it (read/write)? [0] https://docs.ponyorm.com/api_reference.html?highlight=size#cmdoption-arg-auto [1] https://docs.ponyorm.com/api_reference.html?highlight=size#cmdoption-arg-volatile
Volatile attribute values are cached too, but when object is inserted or updated Pony forget values of volatile attributes and should re-read them if the attribute value requested in the same db_session after insert/update. It is a bit less efficient then auto=True, but if you dont't change object too often, the difference should not be too big. For datetme attribute it is possbile to use Python datetime.now default value instead of NOW() SQL function, but it has some limitations. If you use Python's datetime.now default, it is better to store time in UTC timezone.

How do I put text[] type in ORM? http://www.monkeyandcrow.com/blog/tagging_with_active_record_and_postgres/ https://www.postgresql.org/docs/9.6/static/arrays.html
Right now Pony does not support PostgreSQL arrays, but in many cases you can use JSON arrays instead, which are supported by Pony.

Luckydonald
23.01.2017
04:25:23
Bummer. Are json lists as performant? Trying to improve my tagging system, as it has become to slow for answering telegram inline queries in time... I wanted to try out http://www.monkeyandcrow.com/blog/tagging_with_active_record_and_postgres/

Alexander
23.01.2017
10:18:03
I think json lists should be almost as performat as arrays. But in my opinion, neither json lists nor arrays will improve the performance of your query, because it is inherently slow, especially if you want to use in instead of startswith for tag name search. If I'd write such an application, I'd search tags in Python, and then pass found list of tag's ids to the database. To do that, I'd write a python function which accept a substing and return a set of tag ids which names contain that substring: tag_cache = defaultdict(set) # substring -> set(tag_id) @db_session def populate_tag_cache(): for tag in Tag.select(): string = tag.string.lower() for i in range(0, len(string)): for j in range(i+1, len(string)): substing = string[i:j] tag_cache[substring].add(tag.id) def find_tags(substring): return tag_cache[substring.lower()] def find_stickers(query_text): query_text = query_text.lower() tag_ids = find_tags(query_text) - find_text("nsfw") pairs = orm.select( (st.sticker.file_id, max(st.date)) for st in StickerMessage if ( orm.exists(s_t for s_t in st.sticker.tags if s_t.id in tag_ids) or orm.exists(p_t for p_t in st.sticker.sticker_pack.tags if p_t.d in tag_ids) ) ) This is not a complete code (I have no time to help you write entire application), but just a rough idea. I think that for real-time search you should use pre-calculated cache sitting in Python memory and use tha cache to calculate list of tags without hitting the database. But you will need to update cache manually when you add new tags. This complicates architecture, but improves performance

Luckydonald
23.01.2017
10:27:09
I think json lists should be almost as performat as arrays. But in my opinion, neither json lists nor arrays will improve the performance of your query, because it is inherently slow, especially if you want to use in instead of startswith for tag name search. If I'd write such an application, I'd search tags in Python, and then pass found list of tag's ids to the database. To do that, I'd write a python function which accept a substing and return a set of tag ids which names contain that substring: tag_cache = defaultdict(set) # substring -> set(tag_id) @db_session def populate_tag_cache(): for tag in Tag.select(): string = tag.string.lower() for i in range(0, len(string)): for j in range(i+1, len(string)): substing = string[i:j] tag_cache[substring].add(tag.id) def find_tags(substring): return tag_cache[substring.lower()] def find_stickers(query_text): query_text = query_text.lower() tag_ids = find_tags(query_text) - find_text("nsfw") pairs = orm.select( (st.sticker.file_id, max(st.date)) for st in StickerMessage if ( orm.exists(s_t for s_t in st.sticker.tags if s_t.id in tag_ids) or orm.exists(p_t for p_t in st.sticker.sticker_pack.tags if p_t.d in tag_ids) ) ) This is not a complete code (I have no time to help you write entire application), but just a rough idea. I think that for real-time search you should use pre-calculated cache sitting in Python memory and use tha cache to calculate list of tags without hitting the database. But you will need to update cache manually when you add new tags. This complicates architecture, but improves performance
Thank you for your feedback, Im sure to have a look later!

Micaiah
23.01.2017
20:06:47
what front end framework would you guys suggest for flask?

i was using semantic-ui but.. ehh

Cruor99
23.01.2017
20:26:42
I dabble in a bit of everything. Many people swear to react nowadays, though.

Micaiah
23.01.2017
20:28:19
i was looking into react, i just wish there was a python response to react

Rozen
23.01.2017
21:12:27
thank you
XZ x n8 v b vcvheeec 8. e bcxvbb c D u c. out boxeo rcio st 6 y. dcbc xS x 8 bcxD 3 za x x x vi cbc 6 xc 68 b 5, Z tey Unix c. 0 8 6.

Luckydonald
23.01.2017
22:05:18
I think json lists should be almost as performat as arrays. But in my opinion, neither json lists nor arrays will improve the performance of your query, because it is inherently slow, especially if you want to use in instead of startswith for tag name search. If I'd write such an application, I'd search tags in Python, and then pass found list of tag's ids to the database. To do that, I'd write a python function which accept a substing and return a set of tag ids which names contain that substring: tag_cache = defaultdict(set) # substring -> set(tag_id) @db_session def populate_tag_cache(): for tag in Tag.select(): string = tag.string.lower() for i in range(0, len(string)): for j in range(i+1, len(string)): substing = string[i:j] tag_cache[substring].add(tag.id) def find_tags(substring): return tag_cache[substring.lower()] def find_stickers(query_text): query_text = query_text.lower() tag_ids = find_tags(query_text) - find_text("nsfw") pairs = orm.select( (st.sticker.file_id, max(st.date)) for st in StickerMessage if ( orm.exists(s_t for s_t in st.sticker.tags if s_t.id in tag_ids) or orm.exists(p_t for p_t in st.sticker.sticker_pack.tags if p_t.d in tag_ids) ) ) This is not a complete code (I have no time to help you write entire application), but just a rough idea. I think that for real-time search you should use pre-calculated cache sitting in Python memory and use tha cache to calculate list of tags without hitting the database. But you will need to update cache manually when you add new tags. This complicates architecture, but improves performance
Had a thought about that. Currently I already have `1331` unique tags, not sure if that could hit memory very fast. I had a talk with a guy maintaining a big image board, where tagging and complex queries are a big thing. He said, he copies relevant tag data into elastic search and use its power of full text search and bool filtering. As soon as a tag is change it is notified to a redis based task scheduler and processed in background every 2 seconds

Google
Micaiah
24.01.2017
03:23:26
I want to be able to send blog posts to my site from a little PyQt app that I wrote. What would be the safest way to confirm that I sent the post?

Right now I'm thinking about encrypting my secret key and sending it with the json packet which gets turned into a post, but I don't know enough about crypto to know if thats a good idea.

stsouko
24.01.2017
06:13:52
Use https

Let's encrypt free

Luckydonald
24.01.2017
11:12:46
I know, this is probably the wrong group, but you guys know python so well :D Anyone knows a python substitution for sidekiq/redis ("simple background processing for Ruby")? I came along RQ ("Redis Queue") http://python-rq.org/ (via https://devcenter.heroku.com/articles/python-rq )

Ah well, Might have to research further what exactly I need

Romain
24.01.2017
12:28:25
Hello everyone. Any direction to create a postgres database if it doesn't exist? (from within pony)

Alexey
24.01.2017
12:31:57
Hello everyone. Any direction to create a postgres database if it doesn't exist? (from within pony)
Hi Romain, welcome Currently there is no way to create a postgres database from Pony - you only can create tables and indexes if they don't exist. The database itself should be created before it can be used in Pony.

Romain
24.01.2017
12:34:20
OK many thanks for the welcome and the tip

stsouko
24.01.2017
15:26:53
I use RQ

Romain
24.01.2017
16:29:59
Rq?

By the way any news on migration?

Alexander
24.01.2017
19:50:50
The migration tool is almost ready. I really hope we can release before the end of this week. But I want to be sure it does not contain bugs, so we don't receive a flood of messages "the migration tool broke my tables"

Romain
24.01.2017
20:11:11
Excellent news!

Mark
25.01.2017
09:19:18
Hi everyone! I've started using Pony yesterday and haven't actually understood how to use joins yet. In examples I saw when left_join() was used with two for clauses, but when I try to repeat it in my code, I get error like "collection was expected, got "for p in Pond"" Maybe somebody could explain how to use it or point me to docs page where it's already explained?

Alexander
25.01.2017
09:26:35
Hi Mark! That's a great question, and I'm going to give explanation now. But could you give me a favor? Ask this question at http://stackoverflow.com/questions/tagged/ponyorm, so this answer would be available for all people who will look for it. Thanks

Mark
25.01.2017
09:27:12
ok, great!

http://stackoverflow.com/questions/41847908/pony-orm-join-syntax

Alexander
25.01.2017
09:31:13
Ok, give me a few minutes

Google
Mark
25.01.2017
11:01:22
Still no answer :(

Alexander
25.01.2017
11:02:39
Done: http://stackoverflow.com/questions/41847908/pony-orm-join-syntax/41849887#41849887

Mark
25.01.2017
11:08:10
Thank you very much!

Alexander
25.01.2017
11:10:59
In that case it will be three queries, but still much less than N+1

The first query is to retrieve persons, the second one is to retrieve contacts of the first person, and the third one is to retrieve contacts of all other loaded persons

Mark
25.01.2017
11:31:12
Ok, cool. And is there a way to write a query similar to this: SELECT * FROM "public"."person" "p" LEFT JOIN "public"."contacts" "c" ON "p"."id" = "c"."person"

like, select all of columns from joined table

Alexander
25.01.2017
11:36:47
No, Pony does not support such queries, because they are less efficient. In query like this, the same person data will be appeared multiple times, and need to be processed in Python again and again during data retrieving. In most cases it is better to split this query to two where each retrieve data without any unnecessary duplication

Mark
25.01.2017
11:38:48
Ok, thank you very much!

Alexander
25.01.2017
11:40:10
Sure! If you think that StackOverflow answer is on-point, then please mark it as accepted )

Mark
25.01.2017
11:40:26
oh, sorry, of course

Alexander
25.01.2017
11:41:01
Thanks!

Muhammad Afif
25.01.2017
14:23:18
Hi guys, i just started using ponyorm through my telegram bot

I have no idea how to store date, I always get error, I think my date format from python was rigth

Anyone know to deal with this ? Sorry for silly question

Alexander
25.01.2017
14:25:03
Can you give an example of how you do it?

Muhammad Afif
25.01.2017
15:06:57
that is my entity

that is the function that I use to passing the data

Alexander
25.01.2017
15:07:53
And what is the error?

Muhammad Afif
25.01.2017
15:10:39
the error come from the framework (telegram-bot not pony), but from what i learned before, it caused by wrong datatype input

Google
Muhammad Afif
25.01.2017
15:11:14
I want to pass yyyy-mm-dd format to date type, is it possible ?

Alexander
25.01.2017
15:16:53
If score is an instance of Score, then score.taken would be instance of date. If you want to get a date in format of yyyy-mm-dd, you can use isoformat method of date object: score.taken.isoformat()

Muhammad Afif
25.01.2017
15:26:50
Thanks sir, I'll try it

If score is an instance of Score, then score.taken would be instance of date. If you want to get a date in format of yyyy-mm-dd, you can use isoformat method of date object: score.taken.isoformat()
Sir, I found the actual problem, the "max" option on my Score entity doesn't work. I checked on my mysql table, I get int(11) not int(2) as I expected

Alexander
25.01.2017
16:34:27
max option allows to check value assigned to the attribute in Python. If you specify that max=2 that means that the value may be 0, 1, 2, -1, -100, etc., but no greater then 2

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