0
私はDateTimeFieldをpeewee.datetime.datetime.nowまたは今日と比較したいが、それを行うことはできない。コードスニペットは以下のとおりです。今 使用peewee.datetime.datetime.now()
へpythonコードでpeeweeの日付を比較する方法
class subinfo(peewee.Model):
sub_id = peewee.IntegerField()
active = peewee.BooleanField()
sub_type = peewee.IntegerField()
sub_cat = peewee.TextField()
class Meta:
database = locdb
class subscriber(peewee.Model):
sub_id = peewee.IntegerField(unique=True, primary_key=True)
sub_start = peewee.DateTimeField()
sub_end = peewee.DateTimeField()
ref_id = peewee.BigIntegerField()
class Meta:
database = locdb
for row in subscriber.select():
if(row.sub_start >= peewee.datetime.datetime.now):
sub1, created = subinfo.get_or_create(sub_id=row.sub_id, active=True)
if(created == False & sub1.active == False):
q = subinfo.update(active=True).where(sub_id=row.sub_id)
q.execute()
else:
subinfo.get_or_create(sub_id=row.sub_id, active=False)
しかし、私は
File "subsync.py", line 51, in <module>
if(row.sub_start >= peewee.datetime.datetime.now):
TypeError: '>=' not supported between instances of 'datetime.datetime' and 'builtin_function_or_method'
try => toとその子孫を置換してみてください – Mandy8055
>同じエラーが発生する – CPMM