@ponyorm

Страница 7 из 75
Luckydonald
23.11.2016
00:46:33
ValueError: Value -1001032895287 of attr StickerMessage.chat_id is less than the minimum allowed value -2147483648

What can I do?

Using Postgres.

Found https://github.com/ponyorm/pony/issues/18#issuecomment-60963183

Google
Luckydonald
23.11.2016
01:11:07
The datatypes in the docs is somehow lacking. It just is a list, without any description

so size=64 and unsigned=False

But got pony.orm.core.UnexpectedError: Object StickerMessage[-1001032895287] cannot be stored in the database. DataError: integer out of range

James
23.11.2016
09:13:56
An unsigned attribute with size 64 can be represented only in MySQL and Oracle.

Could that be the issue

Alexander
23.11.2016
09:18:38
It is signed in that case

@luckydonald I think that you already created table with integer column type. Try to re-create table so it will use bigint type instead

As you just started working on your project, I think it should be easy to just drop old tables and recreate them

Right now we are working on a migration tool which allow to automatically generate ALTER TABLE... commands to reflect changes in entity defnitions

Luckydonald
23.11.2016
13:24:09
OK. I thought int, size=64 would already create the fitting database type? https://www.postgresql.org/docs/9.1/static/datatype-numeric.html Or is it just used in the internal range checks? Anyway, Required(int, sql_type='bigint', size=64, unsigned=False) indeed works, thank you.

Alexander
23.11.2016
13:25:35
int, size=64 should be enough, but if table was already created Pony does not attempt to modify it when you change model definition in Python

Luckydonald
23.11.2016
13:26:33
Okey, I probably forgot to drop it. Much thanks.

Google
Alexey
23.11.2016
15:20:03
Actually I can scroll it, but the minimap is in the way
fixed can you check if it works for you?

Mikki
24.11.2016
11:48:06
Welcome!

Luckydonald
25.11.2016
09:15:03
It seems I have to specify globals={}, too? Maybe a more verbose error? And/Or warn in https://docs.ponyorm.com/queries.html#using-the-select-by-sql-and-get-by-sql-methods ?

For reference, my data model, if that helps: https://editor.ponyorm.com/user/luckydonald/Tags

Alexander
25.11.2016
09:48:13
> It seems I have to specify globals={}, too? Maybe a more verbose error? In standard Python functions (like eval) if you pass just one dict it called globals: https://docs.python.org/3.6/library/functions.html#eval But such functions typically accept positional arguments only. Probably we need to add handling of situations, where locals passed without globals

> Anyone getting an Idea what that means? What Python version do you use? Try to replace [...] with (...) inside select

Alexander
25.11.2016
10:00:03
.limit(50, offset=offset)

Luckydonald
25.11.2016
10:00:48
That was unexpected to be in limit

Is there a Github page with Wiki, maybe we could start making a list mapping SQL statements to ponyorm?

Alexander
25.11.2016
10:02:33
If offset is called separately it will alter the meaning of previous `limit`call

Luckydonald
25.11.2016
10:02:45
I see

Alexey
25.11.2016
10:21:20
Is there a Github page with Wiki, maybe we could start making a list mapping SQL statements to ponyorm?
Just created one https://github.com/ponyorm/pony/wiki/SQL-statements-represented-in-PonyORM Can you check if you can edit the content?

Luckydonald
25.11.2016
10:50:43
Added that.

Alexey
25.11.2016
10:51:51
Added that.
very cool!

Luckydonald
25.11.2016
10:58:11
How can I check the lower case version of a text field? select( for t in Tag if lower(t.string) == lower("TestText") )

Alexander
25.11.2016
10:58:46
Just as in Python: t.string.lower()

Google
Luckydonald
25.11.2016
10:58:58
Oh, right. My bad.

Romet
28.11.2016
09:59:55
what do you mean by multiple instances?

Luckydonald
28.11.2016
10:05:59
I have multible instances of a telegram bot. Now you can spam that bot, (E.g. by forwarding messages to it) And it need to maintain a state, to get this question-answer style input working. Multible Instances would mean, some could be a little bit faster, and crate the User row already, so hat the else part failes, etc:

Romet
28.11.2016
10:07:02
it should be the library user's responsibility to keep model access synchronous

if you really do have issues with multiple processes, you might want to keep a cache or something for that

to lock access while one worker is already doing it

Alexander
28.11.2016
11:21:07
> How can I make sure I won't get problems with multible instances? In Pony @db_session decorator has retry option. If it is set to value greater than zero, Pony will re-execute function wrapped with db_session specified number of times in case of exception. Contrived example: @db_session(retry=5) def post_message(user_id, user_name, chat_id, message_text): user = get_or_create_user(user_id, user_name) chat = get_or_create_chat(chat_id) message = Message(user=user, chat=chat, text=message_text) def get_or_create_user(user_id, user_name): user = User.get(id=user_id) if user is not None: user.name = name else: user = User(id=user_id, name=user_name) return user def get_or_create_chat(chat_id): return Chat.get(id=chat_id) or Chat(id=chat.id) In this example, if an exception ocurred during db_session execution, Pony will re-execute post_message function up to 5 times. Note that nested db_session s are ingored, only top-level db_session is taken into account.

Romet
28.11.2016
11:25:34
is this a transaction?

will the changes before the exception be rewound?

Alexander
28.11.2016
11:27:42
entering db_session starts a transaction. If exception occurred, all changes during db_session will be rolled back. If retry is specified, Pony will start new transaction and call function again with the same arguments

Romet
28.11.2016
11:28:06
ok, cool :)

Mikki
29.11.2016
08:15:39
Welcome!

Manuel
29.11.2016
14:32:22
Thanks!

Do you know of any other Python related groups on Telegram?

Марк ☢
29.11.2016
14:37:17
There are russian ones. Do you interested in them ?

Manuel
29.11.2016
14:37:37
uff, only speak spanish and english

Roman
29.11.2016
14:45:44
On slack there are huge channels

Romet
29.11.2016
14:47:33
Gitter is great if you're looking for language/library communities

Alexey
29.11.2016
14:50:47
Btw, what do you think of moving to Slack?

Google
Michael
29.11.2016
14:51:41
IRC not mentioned?

Romet
29.11.2016
14:56:46
I use slack but wouldn't use it for something like Pony. Gitter seems more appropriate because it's almost directly related to the repo

Plus once you're there you can subscribe to many more project communities

Luckydonald
29.11.2016
14:57:39
Whats wrong with Telegram?

Alexey
29.11.2016
14:58:26
Nothing wrong We can see that Slack has wider use

Luckydonald
29.11.2016
14:58:34
Do you know of any other Python related groups on Telegram?
There is http://telegram.me/pytg_group for python telegram bots

Romet
29.11.2016
15:15:34
It's usually better for larger communities that need multiple channels to begin with

There's barely any activity in our single chatroom here, don't see why move to a "bigger room"

That's just how I see it anyway

Alexey
29.11.2016
15:16:41
Slack might be more convenient, no?

Romet
29.11.2016
15:17:34
I guess so, for people who don't use Telegram.

Luckydonald
29.11.2016
15:29:24
I'll stay here with you guys :D

Alexander
29.11.2016
15:29:52
I like Telegram more :)

Chris
29.11.2016
19:06:26
Hello, is this an appropriate place to ask a question about how to fix a problem I'm having with Pony?

Alexander
29.11.2016
19:06:54
Hello, sure

Chris
29.11.2016
19:08:05
Thank you :) I've posted a StackOverflow question here: http://stackoverflow.com/questions/40871284/ . I'm being told that a value is being changed outside the current transaction, but I don't think I have multiple transactions occurring

Alexander
29.11.2016
19:15:11
Ok, give me a few minutes :)

Ok, I'll answer on StackOverlow

Chris
29.11.2016
19:19:59
Thank you so much!

Google
Alexander
29.11.2016
19:32:41
Done

Chris
29.11.2016
19:38:31
Thank you for your response! That is very helpful.

I assume this problem will go away once bulk updates are implemented in the orm?

Also, you mention that volatile attributes will not be re-read from the db until the object is saved, so the value might be obsolete when read. I just want to confirm that you are talking about a potential race condition here, if two separate transactions DO, in fact, try to read and modify the object simultaneously?

Alexander
29.11.2016
19:42:50
Well, it may be not easy to invalidate cached attributes in Python after the bulk update was issued. We need to understand which rows were changed, and it may be not easy to do just looking at query in Python. Maybe we can invalidate entire column for all objects of the same type. In the future we'll add List attribute type which will manage columns like order_id automatically

Chris
29.11.2016
19:46:36
Very cool. Thank you!

Alexander
29.11.2016
19:48:27
Sure!

Chris
30.11.2016
16:38:33
@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

https://gist.github.com/chrisshroba/2d3ccdd9f8fe7f066ad57765a29962d0

If you don't have time to look at this, I completely understand!

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