So I'm trying to turn my double query into a join, here's what my peewee select queries look like:
for app in AppInfo.select().limit(5):
for event in EventHistory.select().where(EventHistory.appname==app.appname):
print event
So this is what I tried:
for app in AppInfo.select().join(EventHistory).where(EventHistory.appname==AppInfo.appname).limit(10):
print app
But eh... well seems like I'm doing something very wrong in here.
Here are my models:
class BaseModel(Model):
class Meta:
database = db
class AppInfo(BaseModel):
appname = TextField()
appowner = TextField()
class EventHistory(BaseModel):
appname = TextField(primary_key=True)
time = DateTimeField()
message = TextField()
Aucun commentaire:
Enregistrer un commentaire