peewee

peewee select where not working when using a model instance rather than a model directly

人走茶凉 提交于 2021-02-10 19:51:35
问题 I have an instance of a peewee Model my_table = MyTable() from which I want to select some model instances. I don't understand why this works: In [0] [selection.p_name for selection in my_table.select() if selection.p_type == "Solar"] Out [0] ['Solar, photovoltaic', 'Solar, photovoltaic', 'Solar, photovoltaic', 'Solar, photovoltaic', 'Solar, concentrated solar power', 'Solar, concentrated solar power'] but this doesn't: In [1] selections = my_table.select().where(my_table.p_type=="Solar") In

peewee select where not working when using a model instance rather than a model directly

泄露秘密 提交于 2021-02-10 19:51:11
问题 I have an instance of a peewee Model my_table = MyTable() from which I want to select some model instances. I don't understand why this works: In [0] [selection.p_name for selection in my_table.select() if selection.p_type == "Solar"] Out [0] ['Solar, photovoltaic', 'Solar, photovoltaic', 'Solar, photovoltaic', 'Solar, photovoltaic', 'Solar, concentrated solar power', 'Solar, concentrated solar power'] but this doesn't: In [1] selections = my_table.select().where(my_table.p_type=="Solar") In

peewee - change schema dynamically

半世苍凉 提交于 2021-01-29 11:14:13
问题 I have the same question/problem than this post -> peewee - modify db model meta (e.g. schema) dynamically . I want to change the schema field in my Meta class dynamically. This is my code: class GPSPosition(Model): def __init__(self, esquema, vehiculo, fechaFrom): self.esquema = esquema + '_org' self.vehiculo = vehiculo self.fechaFrom = fechaFrom orgid = BigIntegerField() id = BigIntegerField() vehicleid = BigIntegerField() driverid = BigIntegerField() originaldriverid = BigIntegerField(null

MySQL server has gone away && Lost connection to MySQL server during query

喜你入骨 提交于 2020-12-31 04:36:18
问题一、MySQL server has gone away # #### peewee from peewee import * from peewee import __exception_wrapper__ class RetryOperationalError(object): def execute_sql(self, sql, params=None, commit= True): try : cursor = super(RetryOperationalError, self).execute_sql(sql, params, commit) except OperationalError: if not self.is_closed(): self.close() with __exception_wrapper__ : cursor = self.cursor() cursor.execute(sql, params or ()) if commit and not self.in_transaction(): self.commit() return cursor class RetryMySQLDatabase(RetryOperationalError, MySQLDatabase): def sequence_exists(self, seq): pass

peewee - modify db model meta (e.g. schema) dynamically

寵の児 提交于 2020-12-13 03:47:03
问题 In order to insert same data to same set of tables in different schemas (data about the mobile application where app id is primary key but app is cross-platform and exists on different platforms. Schema per platfrom so pp id does not interfere for tables with it as fk). I already has some infrastructure for it and I wasn't expecting this requirement. For me I see the easiest way is having existing model class binded to some db+schema_1+table_name insert data to first schema then somehow

peewee - modify db model meta (e.g. schema) dynamically

杀马特。学长 韩版系。学妹 提交于 2020-12-13 03:46:24
问题 In order to insert same data to same set of tables in different schemas (data about the mobile application where app id is primary key but app is cross-platform and exists on different platforms. Schema per platfrom so pp id does not interfere for tables with it as fk). I already has some infrastructure for it and I wasn't expecting this requirement. For me I see the easiest way is having existing model class binded to some db+schema_1+table_name insert data to first schema then somehow

peewee - modify db model meta (e.g. schema) dynamically

╄→尐↘猪︶ㄣ 提交于 2020-12-13 03:46:10
问题 In order to insert same data to same set of tables in different schemas (data about the mobile application where app id is primary key but app is cross-platform and exists on different platforms. Schema per platfrom so pp id does not interfere for tables with it as fk). I already has some infrastructure for it and I wasn't expecting this requirement. For me I see the easiest way is having existing model class binded to some db+schema_1+table_name insert data to first schema then somehow

peewee无外键连接

独自空忆成欢 提交于 2020-08-18 11:20:36
# 参考:https://blog.csdn.net/weixin_34273479/article/details/87587183 res = Name.select(Name, User.xxx).join(User, join_type=JOIN.LEFT_OUTER, on=((User.mcc == Name.mcc) & (Name.day == User.day))) for x in res: print(x.user.xxx) 来源: oschina 链接: https://my.oschina.net/u/4265623/blog/4503450