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