I have implemented SQLite3 into my discord bot, everything seems to work and I can commit rows to my db, do a select and retrieve them, however in my local directory for the project I can't see the DB itself.
I've tried looking for commands to log the location to my log file but nothing seems to work either.
Am I missing something?
UPDATE:
This is my function at present:
def add_replay_to_db(filename: str, gamejson: str, playerjson: str, resultjson: str, replaysource: str, messageauthor: str, md5: str):
try:
db_path = '/database/yesman.db'
# Ensure the directory exists
if not os.path.exists(os.path.dirname(db_path)):
fullpath = os.path.dirname(db_path)
os.makedirs(fullpath)
logger.info(f'Database created: {fullpath}')
logger.info(f'Adding {filename} to the SQL database')
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS replay_raw_data (
id INTEGER PRIMARY KEY,
filename TEXT,
game_json TEXT,
player_json TEXT,
result_json TEXT,
replay_source TEXT,
user TEXT,
md5 TEXT
)''')
# INSERT INTO
cursor.execute('INSERT INTO replay_raw_data (filename, game_json, player_json, result_json, replay_source, user, md5) VALUES (?, ?, ?, ?, ?, ?, ?)',
(str(filename), str(gamejson), str(playerjson), str(resultjson), str(replaysource), str(messageauthor), str(md5)))
connection.commit()
# Fetch and print data
cursor.execute('SELECT * FROM replay_raw_data')
rows = cursor.fetchall()
for row in rows:
print(row)
except sqlite3.Error as er:
logger.error(f'{er}')
finally:
if connection:
connection.close()


UPDATE 2:
I installed "Everything" to search for the file, turned out setting
db_path = '/database/yesman.db'Installed the file to my root C:\database directorty. I changed this to
db_path = './database/yesman.db'and it recreate the database in the correct project location.