|
14 | 14 | import random
|
15 | 15 | import re
|
16 | 16 | import sqlite3
|
17 |
| -import subprocess |
| 17 | +import hashlib |
| 18 | +import os |
18 | 19 | import time
|
19 | 20 | import colorlog
|
20 | 21 | import pandas as pd
|
| 22 | +import datetime as dt |
21 | 23 | from datetime import datetime
|
22 | 24 |
|
23 | 25 |
|
24 | 26 | class SQL:
|
25 |
| - def __init__(self, db_name="Users.db"): |
| 27 | + def __init__(self, database_name="Users.db"): |
26 | 28 | """
|
27 | 29 | Initializes the SQL class.
|
28 | 30 |
|
29 | 31 | Args:
|
30 |
| - db_name (str, optional): The name of the database. Defaults to "Users.db". |
| 32 | + database_name (str, optional): The name of the database. Defaults to "Users.db". |
31 | 33 | """
|
32 | 34 | # Set the database name
|
33 |
| - self.db_name = db_name |
34 |
| - |
| 35 | + self.db_name = database_name |
| 36 | + if not os.path.exists(self.db_name): |
| 37 | + self.create_db() |
35 | 38 | # Initialize the connection and cursor to None
|
36 | 39 | self.conn = None
|
37 | 40 | self.cursor = None
|
@@ -481,8 +484,8 @@ def __timestamp() -> str:
|
481 | 484 | str: The current timestamp.
|
482 | 485 | """
|
483 | 486 | now = datetime.now()
|
484 |
| - time = f"{now.strftime('%Y-%m-%d %H:%M:%S')}" |
485 |
| - return time.encode('utf-8').decode('utf-8') |
| 487 | + timestamped = f"{now.strftime('%Y-%m-%d %H:%M:%S')}" |
| 488 | + return timestamped.encode('utf-8').decode('utf-8') |
486 | 489 |
|
487 | 490 | def __only(self, message):
|
488 | 491 | """
|
@@ -591,6 +594,7 @@ def critical(self, message):
|
591 | 594 | )
|
592 | 595 |
|
593 | 596 |
|
| 597 | + |
594 | 598 | class DATABASE:
|
595 | 599 | def __init__(self):
|
596 | 600 | """
|
@@ -1222,7 +1226,6 @@ def api(self):
|
1222 | 1226 |
|
1223 | 1227 | if __name__ == "__main__":
|
1224 | 1228 | db_name = "Users.db"
|
1225 |
| - sql = SQL(db_name=db_name) |
| 1229 | + sql = SQL(database_name=db_name) |
1226 | 1230 | log = LOG(filename="DataBase.log")
|
1227 |
| - sql.create_db() |
1228 | 1231 | DATABASE().api()
|
0 commit comments