mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Start on Upload page
Remove reduntant Exiting text Rename css folder to theme
This commit is contained in:
parent
d85ac5f103
commit
f730ecd0c9
7 changed files with 63 additions and 61 deletions
|
@ -12,19 +12,16 @@ class DBmanager():
|
|||
except ImportError:
|
||||
print("Error: could not import required packages")
|
||||
sys.exit(1)
|
||||
|
||||
env_path = os.path.join('usr', '.env')
|
||||
if not os.path.exists(env_path):
|
||||
print("Error: could not find .env file")
|
||||
sys.exit(1)
|
||||
|
||||
load_dotenv(env_path)
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Connecting to database...")
|
||||
|
||||
try:
|
||||
env_path = os.path.join('usr', '.env')
|
||||
|
||||
if not os.path.exists(env_path):
|
||||
print("Error: could not find .env file")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
load_dotenv(env_path)
|
||||
print("### OnlyLegs Database Manager ###")
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Connecting to database...")
|
||||
|
||||
database = mysql.connector.connect(host=os.environ.get('DB_HOST'),
|
||||
port=os.environ.get('DB_PORT'),
|
||||
database=os.environ.get('DB_NAME'),
|
||||
|
@ -46,52 +43,42 @@ class DBmanager():
|
|||
|
||||
except Error as e:
|
||||
print("Error while connecting to Database!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
self.database = database
|
||||
|
||||
def initialize(self):
|
||||
dir = os.path.join('packages', 'tables')
|
||||
|
||||
if not os.path.exists(dir+'/generate.sql'):
|
||||
if not os.path.exists(os.path.join('packages', 'tables', 'generate.sql')):
|
||||
print("Error: could not find tables directory")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Initializing tables...")
|
||||
|
||||
with open(dir+'/generate.sql', 'r') as f:
|
||||
sql = f.read()
|
||||
|
||||
with open(os.path.join('packages', 'tables', 'generate.sql'), 'r') as sql:
|
||||
cursor = self.database.cursor()
|
||||
query = cursor.execute(sql, multi=True)
|
||||
query = cursor.execute(sql.read(), multi=True)
|
||||
|
||||
i = 0
|
||||
for res in query:
|
||||
#print("Running query...")
|
||||
print(f"Affected {res.rowcount} rows")
|
||||
|
||||
self.database.commit()
|
||||
print(f"Query {i+1}: Affected {res.rowcount} rows")
|
||||
i += 1
|
||||
|
||||
if not os.path.exists(dir+'/junctions.sql'):
|
||||
if not os.path.exists(os.path.join('packages', 'tables', 'junctions.sql')):
|
||||
print("Error: could not find junctions directory")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Initializing junctions...")
|
||||
|
||||
with open(dir+'/junctions.sql', 'r') as f:
|
||||
sql = f.read()
|
||||
|
||||
with open(os.path.join('packages', 'tables', 'junctions.sql'), 'r') as sql:
|
||||
cursor = self.database.cursor()
|
||||
query = cursor.execute(sql, multi=True)
|
||||
query = cursor.execute(sql.read(), multi=True)
|
||||
|
||||
i = 0
|
||||
for res in query:
|
||||
#print("Running query...")
|
||||
print(f"Affected {res.rowcount} rows")
|
||||
|
||||
self.database.commit()
|
||||
|
||||
print(f"Query {i+1}: Affected {res.rowcount} rows")
|
||||
i += 1
|
||||
|
||||
self.database.commit()
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Done!\n")
|
||||
|
||||
def getImage(self, id):
|
||||
|
@ -101,4 +88,4 @@ class DBmanager():
|
|||
cursor = self.database.cursor()
|
||||
cursor.execute(sql, img)
|
||||
|
||||
return cursor.fetchone()
|
||||
return cursor.fetchone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue