Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 64dc288

Browse files
Add files via upload (#14)
### Description <!-- Describe your changes in detail --> ### Motivation & Context <!-- Why is this change required? What problem does it solve? --> ### Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Refactoring (non-breaking change) - [x] Breaking change (fix or feature that would change existing functionality) ### Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have read the [contributing guidelines](https://github.com/DefinetlyNotAI/Test-generator/blob/main/CONTRIBUTING.md) - [x] My change introduces changes to the documentation - [x] I have added tests to cover my changes - [x] All new and existing tests passed ### Related issues <!-- Please link any related issues here. -->
2 parents a78624b + 971c1b5 commit 64dc288

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

DataBase.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,27 @@
1414
import random
1515
import re
1616
import sqlite3
17-
import subprocess
17+
import hashlib
18+
import os
1819
import time
1920
import colorlog
2021
import pandas as pd
22+
import datetime as dt
2123
from datetime import datetime
2224

2325

2426
class SQL:
25-
def __init__(self, db_name="Users.db"):
27+
def __init__(self, database_name="Users.db"):
2628
"""
2729
Initializes the SQL class.
2830
2931
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".
3133
"""
3234
# 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()
3538
# Initialize the connection and cursor to None
3639
self.conn = None
3740
self.cursor = None
@@ -481,8 +484,8 @@ def __timestamp() -> str:
481484
str: The current timestamp.
482485
"""
483486
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')
486489

487490
def __only(self, message):
488491
"""
@@ -591,6 +594,7 @@ def critical(self, message):
591594
)
592595

593596

597+
594598
class DATABASE:
595599
def __init__(self):
596600
"""
@@ -1222,7 +1226,6 @@ def api(self):
12221226

12231227
if __name__ == "__main__":
12241228
db_name = "Users.db"
1225-
sql = SQL(db_name=db_name)
1229+
sql = SQL(database_name=db_name)
12261230
log = LOG(filename="DataBase.log")
1227-
sql.create_db()
12281231
DATABASE().api()

0 commit comments

Comments
 (0)