feat(cmedb): update get_credentials to use proper sqlalchemy syntax
parent
d4fe0c18d8
commit
2f4b4c0a23
|
@ -696,24 +696,23 @@ class database:
|
|||
"""
|
||||
# if we're returning a single credential by ID
|
||||
if self.is_credential_valid(filter_term):
|
||||
results = self.conn.query(self.UsersTable).filter(
|
||||
q = select(self.UsersTable).filter(
|
||||
self.UsersTable.c.id == filter_term
|
||||
).all()
|
||||
)
|
||||
elif cred_type:
|
||||
results = self.conn.query(self.UsersTable).filter(
|
||||
q = select(self.UsersTable).filter(
|
||||
self.UsersTable.c.credtype == cred_type
|
||||
).all()
|
||||
)
|
||||
# if we're filtering by username
|
||||
elif filter_term and filter_term != '':
|
||||
results = self.conn.query(self.UsersTable).filter(
|
||||
q = select(self.UsersTable).filter(
|
||||
func.lower(self.UsersTable.c.username).like(func.lower(f"%{filter_term}%"))
|
||||
).all()
|
||||
)
|
||||
# otherwise return all credentials
|
||||
else:
|
||||
results = self.conn.query(self.UsersTable).all()
|
||||
q = select(self.UsersTable)
|
||||
|
||||
self.conn.commit()
|
||||
self.conn.close()
|
||||
results = asyncio.run(self.conn.execute(q)).all()
|
||||
return results
|
||||
|
||||
def is_user_valid(self, user_id):
|
||||
|
|
Loading…
Reference in New Issue