@ponyorm

Страница 70 из 75
Carel
22.08.2018
14:01:26
I use Mysql, for this reason it’s important for me this question ?
I fell asleep on you. I’m just another user so won’t be much help beyond what I said already.

Jim
28.08.2018
11:15:22
Is she Alexander's replacement during his hollidays? ??

Juan
28.08.2018
11:17:07
She looks like an expert in PonyORM

Matthew
28.08.2018
11:17:51
@metaprogrammer @akozlovsky is it possible to make this group private, kick the bots then have a new group for genuine pony users to be filtered through?

Google
Alexander
28.08.2018
11:47:54
I'll try to do this after returning from my trip

Vitaliy
31.08.2018
16:55:11
Hi everyone! How do you deal with error like following: pony.orm.core.UnrepeatableReadError: Value of VirtualServer.discount for **** was updated outside of current transaction (was: Decimal('0.84999999999999997779553950749686919152736663818359375'), now: Decimal('0.8500')) I though this trouble can appear only if using a float field, not Decimal one. But recently (after upgrading to mysql 8) I encountered it again. Field definition is: discount = Required(Decimal, 10, 4, default=1, min=0, max=1), so it should be quantized to 4 digits. Is there only way to set volatile=True or optimistic=False?

Jim
31.08.2018
16:59:01
https://docs.ponyorm.com/api_reference.html#volatile-option

Vitaliy
31.08.2018
17:03:31
Yes, I know it. I just noticed following in docs: optimistic (bool) True means this attribute will be used for automatic optimistic checks, see Optimistic concurrency control section. By default, this option is set to True for all attributes except attributes of float type - for float type attributes it is set to False by default. @akozlovsky maybe you should set optimistic to False for Decimals too?

Alexander
31.08.2018
18:21:09
Hi Vitaliy! Are you sure the column in the database is declared as DECIMAL and not as REAL?

Vitaliy
01.09.2018
08:11:03
Hi Alexander! Just checked: price decimal(10,2) NOT NULL, discount decimal(10,4) NOT NULL

Tom
04.09.2018
00:25:37
How are the migration unittest run? This works really well in the main orm branch: PYTHONPATH=../ponytest/ python3 -m unittest discover -v but in orm-migrations pony/orm/examples/test_operations.py causes a failure (see https://github.com/ponyorm/pony/pull/377) even though I don't think it is meant to be a test and pony/tests/test_migrations/ doesn't seem to be found.

Mener
11.09.2018
06:27:21
Is this a ico group?

Matthew
11.09.2018
06:46:04
no

ワスドフ(Wasdf)
19.09.2018
15:06:24
Hey! Just a question, can i put new @property inside a created db.Entity, or i can put inheriting a class (like a method)?

Awesome library!

Alexander
19.09.2018
15:07:03
Hola! Yes you can.

ワスドフ(Wasdf)
19.09.2018
15:08:22
Hola! Yes you can.
Only put a new property? okey, thanks!

Google
Alexander
19.09.2018
15:11:16
If I get you correctly you can do like this: from pony.orm import * db = Database('sqlite', ':memory:') class Test(db.Entity): a = Required(str) db.generate_mapping(create_tables=True) def foo(self): return 52 Test.foo = property(foo) with db_session: t = Test(a='123') commit() print(t.foo) select(t for t in Test if t.foo == 52).show()

And what do you mean by put inheriting a class (like a method)?

ワスドフ(Wasdf)
19.09.2018
15:14:08
And what do you mean by put inheriting a class (like a method)?
class ProductMixin(object): def get_name_and_price(self): return "%s (%s)" % (self.name, self.price) class Product(db.Entity, ProductMixin): name = Required(str, unique=True) price = Required(Decimal)

like the example of the official doc

but with @property

but.. thinking it better, it has no sense

xD

Alexander
19.09.2018
15:15:03
Okay. It will work both ways.

ワスドフ(Wasdf)
19.09.2018
15:15:34
cool, thanks a lot!

omg, it works with aaaaall options, awesome xD

Alexander
19.09.2018
15:47:34
You are welcome.

Krzysztof
21.09.2018
00:54:32
Hello. I have a question about functions in queries. I understand that I can't use my own functions in them – that wouldn't make sense anyway. There is list of functions that can be used in queries in the API documentation, but there is one thing that bothers me. On the "Queries" page of the documentation there is this example: `select(o for o in Order if o.customer in select(c for c in Customer if c.name.startswith('A')))[:]`. So there is a startswith function of str. So, which functions can I really use? Is there a complete list somewhere?

Alexander
21.09.2018
05:36:14
First of all: https://docs.ponyorm.com/queries.html#functions-which-can-be-used-inside-a-query

And you CAN use your own functions: https://docs.ponyorm.com/entities.html#hybrid-methods-and-properties

Krzysztof
21.09.2018
09:07:58
There is no information about startswith in the first link you gave me.

And about the second link – yes, I know, I said it wouldn't make sense to use my own functions *inside* a query.

I'm sorry if I wasn't clear enough.

Alexander
21.09.2018
10:54:19
Hi Krzysztof! Technically speaking, statswith is not a standalone function, but a method of str class. You are right that the full list of supported methods is missed from documentation. We need to add it. Currently, the following methods can be translated: str.startswith str.endswith str.strip str.lstrip str.rstrip datetime.date datetime.now date.today

Krzysztof
21.09.2018
11:00:42
That's great, thank you. :-)

Google
Krzysztof
21.09.2018
11:01:14
And what about other time libraries functions that comply with datetime API? Would it be supported as well?

Alexander
21.09.2018
11:02:06
What do you mean, can you give an example?

Krzysztof
21.09.2018
11:05:30
Pendulum could be an example: https://pendulum.eustace.io/faq/

Alexander
21.09.2018
11:26:55
Theoretically this is possible, but I do not think that we will be able to add the support of other datetime libraries in the near future, because there are more urgent tasks Speaking of other datetime libraries, support can consist of two separate things: 1) Silent conversion of passed datetime parameter value to correct corresponding database type 2) Support of additional datetime methods For (1) we need to know corresponding database datatype for all supported databases. It may be tricky, for example, to store timezone-aware datetime in SQLite database. For (2) we need to know an equivalent SQL expression for each Python method we want to support, for all supported databases Currently, when working with date and time in Pony, you need to use standard timezone-naive values. It may be better to convert all datetime values to UTC before storing them in database. That way each datetime value will be unambiguous

Krzysztof
21.09.2018
11:27:53
OK, thank you very much for your support! :-)

Alexander
21.09.2018
11:28:15
You are welcome

@
22.09.2018
10:37:46
Is there any way to generate Entities python code from an existing postgres database?

ワスドフ(Wasdf)
22.09.2018
10:42:29
ponyorm/pony · GitHub https://github.com/ponyorm/pony/tree/orm-migrations/pony/migrate

And i remember that there is a third party lib for postrgre

Permalink Bot
22.09.2018
10:43:12
Alexander
22.09.2018
10:43:55
Migrate cannot be helpful here.

ワスドフ(Wasdf)
22.09.2018
10:44:45
Migrate cannot be helpful here.
Yep, i tried it and it generates an only one empty entity xD

In my case on mysql database

Alexander
22.09.2018
10:45:27
You can try this library, it should create entity definitions for simple cases https://github.com/abetkin/pony-inspect

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