Alexander
It is signed in that case
Alexander
@luckydonald I think that you already created table with integer column type. Try to re-create table so it will use bigint type instead
Alexander
As you just started working on your project, I think it should be easy to just drop old tables and recreate them
Alexander
Right now we are working on a migration tool which allow to automatically generate ALTER TABLE... commands to reflect changes in entity defnitions
Lucky
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
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
Lucky
Okey, I probably forgot to drop it. Much thanks.
Lucky
Alexey
Alexey
Mikki
Welcome!
Lucky
File "/usr/local/lib/python3.5/site-packages/pony/orm/core.py", line 627, in _exec_raw_sql
assert locals is None
AssertionError
Lucky
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 ?
Lucky
Anyone getting an Idea what that means?
Lucky
For reference, my data model, if that helps: https://editor.ponyorm.com/user/luckydonald/Tags
Lucky
Trying to get a sticker from the StickerMessage table, with given message_id and chat_id(==user_id)
Alexander
> 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
Alexander
> Anyone getting an Idea what that means?
What Python version do you use?
Try to replace [...] with (...) inside select
Lucky
Lucky
Lucky
Works, awesome. Thanks
Lucky
How can I use the OFFSET in the pythonic style?
I try to write the SQL in the first line as python query below
Alexander
.limit(50, offset=offset)
Lucky
That was unexpected to be in limit
Lucky
Is there a Github page with Wiki, maybe we could start making a list mapping SQL statements to ponyorm?
Alexander
If offset is called separately it will alter the meaning of previous `limit`call
Lucky
I see
Lucky
Added that.
Alexey
Lucky
How can I check the lower case version of a text field?
select(
for t in Tag if lower(t.string) == lower("TestText")
)
Alexander
Just as in Python: t.string.lower()
Lucky
Oh, right. My bad.
Lucky
Romet
what do you mean by multiple instances?
Lucky
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:
Lucky
Romet
it should be the library user's responsibility to keep model access synchronous
Romet
if you really do have issues with multiple processes, you might want to keep a cache or something for that
Romet
to lock access while one worker is already doing it
Alexander
> 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
is this a transaction?
Romet
will the changes before the exception be rewound?
Alexander
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
ok, cool :)
Mikki
Welcome!
Anonymous
Thanks!
Anonymous
Do you know of any other Python related groups on Telegram?
Mark ☢️
There are russian ones. Do you interested in them ?
Anonymous
uff, only speak spanish and english
Roman
On slack there are huge channels
Romet
Gitter is great if you're looking for language/library communities
Alexey
Btw, what do you think of moving to Slack?
Michael
IRC not mentioned?
Romet
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
Romet
Plus once you're there you can subscribe to many more project communities
Lucky
Whats wrong with Telegram?
Alexey
Nothing wrong
We can see that Slack has wider use
Alexey
Romet
It's usually better for larger communities that need multiple channels to begin with
Romet
There's barely any activity in our single chatroom here, don't see why move to a "bigger room"
Romet
That's just how I see it anyway
Alexey
Slack might be more convenient, no?
Romet
I guess so, for people who don't use Telegram.
Lucky
I'll stay here with you guys :D
Alexander
I like Telegram more :)
Anonymous
Hello, is this an appropriate place to ask a question about how to fix a problem I'm having with Pony?
Alexander
Hello, sure
Anonymous
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
Ok, give me a few minutes :)
Alexander
Ok, I'll answer on StackOverlow
Anonymous
Thank you so much!
Alexander
Done
Anonymous
Thank you for your response! That is very helpful.
Anonymous
I assume this problem will go away once bulk updates are implemented in the orm?
Anonymous
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
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
Anonymous
Very cool. Thank you!
Alexander
Sure!