def get_apikey(self, key, secret): return ApiKey().select(ApiKey, Account).join( Account, on=ApiKey.account_id == Account.account_id, attr='account_id').where(ApiKey.key == key, ApiKey.secret == secret, ApiKey.deleted == 0, Account.status == 'active').get()