Mikki
Welcome! :)
ସ୍ୱାଧୀନ 🇮🇳 🐕🎧🗺
Anonymous
Hello guys :)
ସ୍ୱାଧୀନ 🇮🇳 🐕🎧🗺
Hello
Lucky
Hey
Mikki
Welcome :)
Angel
welcome!
Lucky
Hi!
Lucky
It seems it won't delete correctly.
Lucky
I realized I probably just could replace (reassign) the .state :D
Not sure why that above happens, tho.
Alexander
The real operation is postponed until commit or flush.
I'm not sure it is a good idea to delete a row and right after that create a new row with the same primary key. Maybe it is better to assign new state field to a existing row.
And even better is probably to have state field directly inside the User object
Lucky
Alexander
I think you are overmodest :)
If each object type (User, Chat, Message, etc.) has corresponding type attribute, the cleanup may be relatively simple too, something like that:
@db_session
def do_cleanup()
db.execute('update "user" set "state" = 0')
db.execute('update "message" set "state" = 0')
db.execute('update "chat" set "state" = 0')
Mikki
Welcome!
Anonymous
Hey everyone!
Anonymous
Just join the group
Anonymous
starting to learn pony
Angel
welcome
Angel
on a non related question, in: def send_message(text, chat_id=169582347, parse_mode=None):
Angel
def send_message(text, chat_id=169582347, parse_mode=None):
Angel
which are *arg and **kwargs
Rozen
mmm if i were you i'd ask here: https://telegram.me/pythontelegrambotgroup
Angel
Angel
I realize my mistake thanks it is decided on the call not the definition
Angel
Anonymous
Anonymous
Hello guy
I would like to discuss a diagram for the web creator.
This is about relations and that relations always have fields on both tables involved.
I would suggest something like this as an option (see image)
Anonymous
Guys* :)
Lucky
Pony genernates you Fields in both classes, so you can reach one from another
Alexey
that's correct - having the relationship attributes in both entities allows traversing these attributes, so you can reach one object from another.
Colin, let me understand, why you'd like to omit the relationship attribute in the User entity? How does it help?
Alexey
Actually, you are not the first person asking about this. My understanding is that this way it is more SQL table oriented, because in the database there is no column for this relationship in the 'User' table
Alexey
probably we could have two views in the editor 'object view' and 'table view'. Another option is to have the relation attributes separated from the regular attributes - say data attributes at the top and relationship attributes under a line at the bottom in each entity
Anonymous
are both relational fields created by pony actually created in the database or is this just in the code for representation?
Alexey
the code only
for one-to-many relationship the field is created in one table only
Alexey
you can see that if you open one of the specific database with SQL tab (SQLite, MySQL, etc)
Anonymous
okey so in this case it only helps me in the overview of the online tool
Anonymous
the "object" and "table" view would be very nice
Alexey
what technology are you using for working with the database, once the diagram is created?
Anonymous
for now i using django models
Anonymous
and for sure postgres as database
Alexey
btw, we plan to add Django tab, where you can get Django models for your diagram
Anonymous
🙏 thanks :)
Alexey
what about having the attributes which will not be created as fields in the database of different color on the diagram? say gray?
Anonymous
would be helpful as well
Anonymous
the problem i have is that is gets very fast unclear
Anonymous
Lucky
Another thing which struck me, was that you can't Zoom.
Anonymous
yes me 2
Anonymous
have you ever used enterprise architect?
Alexey
currently you can zoom using the browser zoom
Alexey
never used the enterprise architect. what we can pick from it?
Lucky
Is there planned to be able to import pony code?
Anonymous
one cool thing is to create modules with specific models in each of them
from that you have a view in each module to see only the tables related and the relations to other module-tables
Alexey
Anonymous
sure
Anonymous
Alexey
and the diagram?
Anonymous
these are the modules and models inside
Anonymous
Anonymous
is just an example
Alexey
ok, I see, thanks!
Alexey
Sorry guys, I need to step out for an hour
But let's continue this conversation, it is very cool that you can give us your feedback
Anonymous
oke bye :)
Lucky
how that could be heplful? what workflow do you see in this case?
2 cases:
- apply changes in code easily or be able to create them in code first, and later visualize them
- there is currently no import at all, It would be handy if I could enter a database i created hundreds of commits earlier, to have a look at the data at that time.
Having really big databases/many tables, entering then manually can be a hassle.
Maybe there could be an import module for other models too. That part maybe open source, so users can contribute other mappers, e.g. Importing Django Models into Pony
Anonymous
yes would be very nice
Lucky
But I often change models in Source code, and manual doing that in the editor later sometimes I tend to forget something.
Alexey
Lucky
The line
db_user.last_used = orm.raw_sql("NOW()")
Fails with
TypeError: Attribute WebSession.last_used: expected type is 'datetime'. Got: <pony.orm.ormtypes.RawSQL object at 0x7eff3eaf3b38>
The schema looks like this:
class WebSession(db.Entity):
id = PrimaryKey(UUID)
bot_token = Optional(str, nullable=True)
user = Optional(User)
web_token = Optional(str)
created = Required(datetime, sql_default='NOW()')
last_used = Required(datetime, sql_default='NOW()')
Alexander
RawSQL is just a text inside an SQL query. It evaluates on the database side. If you perform change in Python, assign Python value:
from datetime import datetime
...
db_user.last_user = datetime.now()
Lucky
I was hoping I could have used NOW() to be independent of the script time(zone).
Alexander
Hmm, so you mean that that Raw SQL value just used when UPDATE command will be sent to the database later? Maybe we can add this in the future.
Until that, you can add a trigger which will update the column automatically:
http://stackoverflow.com/questions/9556474/how-do-i-automatically-update-a-timestamp-in-postgresql/26284695#26284695
Lucky
Lucky
Having my boring old Sticker search query again:
pairs = orm.select(
(st.sticker.file_id, max(st.date))
for st in StickerMessage
for t in st.sticker.tags
if (query_text.lower() in t.string.lower() or query_text == st.sticker.emoji)
).order_by(orm.desc(2), 1).limit(50, offset=offset)
How would I best exclude StickerMessages where any of the Tags t.string.lower() == "blocked tag"?
Alexander
and not exists(t for t in st.sticker.tags if t.string.lower() == "blocked tag")
Lucky
I already have for t in st.sticker.tags, this can't be integrated?