def insert(self, name: str, command: str, server: Server):
""" Inserts a new command into the table.
"""
if not name or not command: # pragma: no cover
# TODO: raise some exception
return False
if self.sql_type is SQLType.sqlite:
return await self._insert_lite(name, command, server)
else: # pragma: no cover
self.cursor.execute(
self.query("INSERT INTO commands VALUES (%(name)s, %(command)s, %(server)s) ON CONFLICT DO NOTHING"),
{"name": name, "command": command, "server": server.id})
self.connection.commit()
if self.cursor.rowcount > 0:
return True
return False
评论列表
文章目录