This repository has been archived on 2022-06-13. You can view files and clone it, but cannot push or open issues or pull requests.
KassouBot/src/utils/db.py

23 lines
499 B
Python
Raw Normal View History

2021-06-03 08:07:53 +02:00
import sqlite3
2021-06-03 08:40:40 +02:00
class Database:
2021-06-03 08:30:17 +02:00
def __init__(self):
2021-06-03 09:03:01 +02:00
path = "src/db/bot.sqlite3"
2021-06-03 08:30:17 +02:00
if not self.isDatabaseExists(path):
self.createDB(path)
self.con = sqlite3.connect(path)
print("DB Open")
def isDatabaseExists(self, path):
try:
2021-06-03 09:03:01 +02:00
open(path, "r")
2021-06-03 08:30:17 +02:00
except FileNotFoundError:
return False
else:
return True
def createDB(self, path):
print("Creating DB...")
open(path, "x")