Matt
🙂
Matthew
I think the kind of support you offer fore free in here, but via private messages / email would work
Matthew
so you just need a webpage and some payment buttons :)
Alexey
Great! We are working on such a page. We are going to provide one time and subscription payments via Stripe. Do you think we'd better use a service (e.g. Patreon, OpenCollective) or it doesn't matter?
Matt
Probably doesn’t matter, depends what’s easier for you. The most important thing is what exactly you plan to “sell” ;)
Alexey
I see, cool
Matthew
Start with stripe and add others if there is demand later
Alexey
👍
Matthew
pony.orm.core.UnrepeatableReadError: Value of X.y for X[493] was updated outside of current transaction (was: datetime.datetime(2019, 2, 23, 16, 22, 14, tzinfo=tzoffset(None, -18000)), now: datetime.datetime(2019, 2, 23, 21, 22, 14))
Matthew
Is this the timezone confusing pony?
Matthew
field is a datetime.datetime
Alexander
PonyORM doesn't support timezones. You need to convert datetime to datetime without timezone, probably in UTC
Matt
That seems pretty reasonable, since time stamp in DB should always be UTC anyways
Matthew
Ah ok thank you
Matt
@matthewrobertbell pytz can help you with the more tedious aspects
Matt
https://eureka.ykyuen.info/2015/04/17/python-convert-a-timezone-aware-datetime-to-utc-datetime-using-pytz/
Matthew
I'm using dateutil which seems fine
Matt
Or that
Anonymous
hello everyone, I want use default value None, But I got "Default value for required attribute Position.exit_order cannot be None" Could someone please help me?
Jim
maybe something like it : aa = orm.Required(str, default=None)
Jim
you should use Optional
Jim
show us your code
Anonymous
Jim
the exit order should be Optional since Required means "could not be None"
Anonymous
I got it, Thanks
Anonymous
Anonymous
I got this, I dont know what happened
Anonymous
this is my code
Anonymous
Alexander
https://docs.ponyorm.org/relationships.html#multiple-relationships-between-two-entities
Alexander
each relationship defined using exactly two attributes. Like: Group.students <-> Student.groups Order.products <-> Product.orders Order.user <-> USer.orders etc In your class you have three attributes in Position which are pointed to Order, but only one attribute in Order which is pointed to Position
Anonymous
Anonymous
Now, in Position, I want use two order, I got error
Alexander
Then you need to have two attributes in Order, like "entry_positions" (which refers to all Position which has entry_order linked to this specific order), and "exit_positions"
Anonymous
bingo thanks sincerely,
Anonymous
I think I missed some conception, it's very hard for me. Why does this work
Alexander
Each relationship is two-sided. When A refers to B in some way, this means that B refers to A in some corresponding way Relationships are modeled in database with using of additional columns (for one-to-many relationships) or intermediary tables (for many-to-many relationships) You can search some information about Entity-Relationship model. Pony entities and relationships are similar to ER model with "crow notation"
Anonymous
yeah, Thanks again😘
Anonymous
Hi guys!
Anonymous
Does pony support "datetime - datetime" in queries?
Anonymous
TypeError: Unsupported operand types 'datetime' and 'datetime' for operation '-'
Anonymous
This is the context of the problematic part from my query `(datetime.utcnow() - car.created_at).total_seconds() / timedelta(days=1).total_seconds()` and in python this normally returns 0.5 for if half a day has passed
Anonymous
https://github.com/ponyorm/pony/issues/438 I've created an issue, if that's relevant
Alexander
Thanks, think we need to add this operation. It seems currently only datetime - timedelta is supported
Anonymous
@sashaaero considered adding it three months ago, https://github.com/ponyorm/pony/issues/115#issuecomment-451453989 maybe he has already some progress on it :)
Anonymous
Thanks!
Anonymous
Meanwhile, trying to think of workarounds, I think the best way is to create float attribute days_passed_since_created_at and fill it before each query
Alexander
Yeah, Anon . Since now Im fully focused on migrations (because we decide to force the implementation) all these things are delayed. Sorry. We understand that some of these small additions can be done quickly, but everytime we distract from the main goal we postpone it very hard. At the moment the most Pony users ask for migrations and we put all our efforts to this goal.
Anonymous
Migrations are very welcome, though!❤ 😊
Matt
Migrations 100% most needed! Thanks guys!
Vitaliy
Hello Alexander! I've discovered a bug, that dropped some of my data in production. And I have no backup.
Vitaliy
I have such entity: class Payment(EntityMixin,Entity): id = PrimaryKey(int, auto=True) paid = Required(bool, default=False) created = Required(datetime, default=<built-in method utcnow of type object at 0x7f9d1ea00d80>) updated = Optional(datetime) type = Required(str, 16) amount = Required(Decimal, 10, 2) term = Optional(Json, default={}) rate = Required(Decimal, 10, 4, default=Decimal('1')) metadata = Required(Json, default={}) method = Optional(PayMethod) user = Optional(User) servers = Set(Server)
Vitaliy
I want to cleanup old unpaid payments: select(p for p in Payment if not p.paid and coalesce(p.updated, p.created) + timedelta(days=31) < datetime.utcnow())
Vitaliy
This query translates into: SELECT "p"."id", "p"."paid", "p"."created", "p"."updated", "p"."type", "p"."amount", "p"."term", "p"."rate", "p"."metadata", "p"."method", "p"."user" FROM "payment" "p" WHERE ("p"."paid" OR (coalesce("p"."updated", "p"."created") + INTERVAL '744:0:0' DAY TO SECOND) < %(p1)s) LIMIT 10 {'p1':datetime.datetime(2019, 3, 24, 8, 24, 7, 469374)}
Vitaliy
ACHTUNG!!! ("p"."paid" OR (coa.... ___________________________^ OR here, not AND
Alexander
Hmmm.... really? I'll look into it immediately
Vitaliy
But if I change query to: select(p for p in Payment if coalesce(p.updated, p.created) + timedelta(days=31) < datetime.utcnow() and not p.paid) all is fine: SELECT "p"."id", "p"."paid", "p"."created", "p"."updated", "p"."type", "p"."amount", "p"."term", "p"."rate", "p"."metadata", "p"."method", "p"."user" FROM "payment" "p" WHERE (coalesce("p"."updated", "p"."created") + INTERVAL '744:0:0' DAY TO SECOND) < %(p1)s AND NOT ("p"."paid") LIMIT 10 {'p1':datetime.datetime(2019, 3, 24, 8, 26, 20, 256209)}
Vitaliy
This is postgres, maybe it works in another databases
Alexander
Are you sure this is the same query? In SQL you have LIMIT 10 which is not present in your Python query
Alexander
Is query really specified as a generator expression, or constructed step by step with lambda?
Alexander
I tested on SQLite and Postgres abd it works correctly
Vitaliy
Yes, this is right queries, I ran them in console and debugged with .limit() and .show()
Vitaliy
No, query is not constructed step by step
Vitaliy
>>> select(p for p in Payment if coalesce(p.updated, p.created) + timedelta(days=31) < datetime.utcnow() and not p.paid)[0:1] SELECT "p"."id", "p"."paid", "p"."created", "p"."updated", "p"."type", "p"."amount", "p"."term", "p"."rate", "p"."metadata", "p"."method", "p"."user" FROM "payment" "p" WHERE (coalesce("p"."updated", "p"."created") + INTERVAL '744:0:0' DAY TO SECOND) < %(p1)s AND NOT ("p"."paid") LIMIT 1 {'p1':datetime.datetime(2019, 3, 24, 8, 51, 46, 982292)} [] >>> select(p for p in Payment if not p.paid and coalesce(p.updated, p.created) + timedelta(days=31) < datetime.utcnow())[0:1] SELECT "p"."id", "p"."paid", "p"."created", "p"."updated", "p"."type", "p"."amount", "p"."term", "p"."rate", "p"."metadata", "p"."method", "p"."user" FROM "payment" "p" WHERE ("p"."paid" OR (coalesce("p"."updated", "p"."created") + INTERVAL '744:0:0' DAY TO SECOND) < %(p1)s) LIMIT 1 {'p1':datetime.datetime(2019, 3, 24, 8, 52, 4, 768955)} [Payment[16207]] >>>
Vitaliy
Here is screen dump made just now
Alexander
What Python version do you use?
Vitaliy
Python 3.7.0 (default, Aug 22 2018, 09:16:41) [GCC 6.3.0 20170516] on linux
Vitaliy
pony 0.7.9
Alexander
It seems to be caused by bytecode changes in 3.7
Alexander
Will fix it today and release new Pony version
Vitaliy
Thank you
Alexander
We tried to fix decompiler today, but It turns out to be pretty complex task. It is doable, but requires some time. I think it is better not to use Pony with Python 3.7 until the fix will be ready: conditions of type not A and B can be incorrectly translated. If possible, rollback to Python 3.6 Actually Python 3.7 is the first Python version where Pony decompiler may work incorrectly. This means that we need to change the way decomper works. I have a plan, but need about a week to implement it. This will be a high-priority task
Anonymous
Good morning
Anonymous
I am unable to download a diagram (as an image) from the editor
Anonymous
not a big deal but wanted to let you know :)
Alexander
Hello. What's wrong with it? What's happening when you try?
Anonymous
get a 404 reply from 45.79.156.60