feat(cmedb): update add_share to use proper sqlalchemy syntax

main
Marshall Hallenbeck 2023-03-06 17:49:21 -05:00
parent dc417119b6
commit 042f67ee73
1 changed files with 6 additions and 5 deletions

View File

@ -160,7 +160,7 @@ class database:
# )''') # )''')
def add_share(self, computer_id, user_id, name, remark, read, write): def add_share(self, computer_id, user_id, name, remark, read, write):
data = { share_data = {
"computerid": computer_id, "computerid": computer_id,
"userid": user_id, "userid": user_id,
"name": name, "name": name,
@ -168,10 +168,11 @@ class database:
"read": read, "read": read,
"write": write, "write": write,
} }
q = insert(self.SharesTable).values(data) share_id = asyncio.run(self.conn.execute(
self.conn.execute(q) insert(self.SharesTable).values(share_data).returning(self.SharesTable.c.id)
self.conn.commit() )).scalar_one()
self.conn.close()
return share_id
def is_share_valid(self, share_id): def is_share_valid(self, share_id):
""" """