2
0
mirror of https://github.com/Nick80835/microbot synced 2025-09-02 15:35:43 +00:00

remove database stuff and notes

This commit is contained in:
Nick80835
2020-04-05 19:53:20 -04:00
parent 1d0bae96f2
commit 9700c258ef
4 changed files with 0 additions and 150 deletions

View File

@@ -1,37 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
from databases import Database as db
class Database():
def __init__(self, client):
self.db = db("sqlite:///database.db")
client.loop.run_until_complete(self.db.connect())
async def ensure_table(self, table, columns):
await self.db.execute(f"create table if not exists {table} ({' TEXT, '.join(columns) + ' TEXT'})")
return ", ".join(columns)
async def single_row_write(self, table, columns, row, value):
column_string = await self.ensure_table(table, columns)
await self.db.execute(f"delete from {table} where {columns[0]} = '{row}'")
await self.db.execute(f"insert into {table}({column_string}) values ('{row}', '{value}')")
async def single_row_delete(self, table, columns, row):
await self.ensure_table(table, columns)
await self.db.execute(f"delete from {table} where {columns[0]} = '{row}'")
async def single_column_readall(self, table, columns, row):
await self.ensure_table(table, columns)
fetched_tuple = await self.db.fetch_all(f"select {row} from {table}")
fetched_list = [item[0] for item in fetched_tuple]
return fetched_list
async def single_row_read(self, table, columns, row):
await self.ensure_table(table, columns)
content = await self.db.fetch_one(f"select {columns[1]} from {table} where {columns[0]} = '{row}'")
if content:
return content[0]
else:
return None