diff --git a/dbUtils/dbCommands.py b/dbUtils/dbCommands.py new file mode 100755 index 00000000..98cef912 --- /dev/null +++ b/dbUtils/dbCommands.py @@ -0,0 +1,66 @@ +import mariadb +import sys + +cursor = mariadb.cursors.Cursor + +#Connects to the databse with the given user +def connect(dbName): + # Connect to MariaDB Platform + try: + conn = mariadb.connect( + user="root", + password="KyKvMdRt586591!*", + host="db.keydev.me", + port=3306, + database=dbName + ) + except mariadb.Error as e: + print(f"Error connecting to MariaDB Platform: {e}") + sys.exit(1) + cur = conn.cursor() + + return cur + +def getColumnNames(cursor, table): + command = "SHOW COLUMNS FROM " + table + cursor.execute(command) + colName = [] + index = 0 + for row in cursor: + colName.append(row[0]) + return colName + +def getForeignKeys(cursor, table): + command = "SHOW INDEX FROM " + table + cursor.execute(command) + colName = [] + index = 0 + for row in cursor: + if not row[2] == "PRIMARY": + colName.append(row[4]) + return colName + +def getPrimaryKey(cursor, table): + command = "SHOW INDEX FROM " + table + cursor.execute(command) + index = 0 + for row in cursor: + if row[2] == "PRIMARY": + pk = row[4] + return pk + + + +''' +tableProject = dbGetTableColNames(cursorProjects, "project") +# Get Cursor +curProject.execute("SELECT name, description FROM project") + +for (name, description) in curProject: + print(f"Name : {name}, What: {description}") + + +cursor.execute("select * from project") + for row in curProject: + print(row) +''' diff --git a/dbUtils/dbInventory.py b/dbUtils/dbInventory.py new file mode 100755 index 00000000..1f13b8ef --- /dev/null +++ b/dbUtils/dbInventory.py @@ -0,0 +1,78 @@ +import dbCommands as db + +#Connect to the database +cursorProjects = db.connect("minibase_projects") + +# This list must represent what the database contains as tables. +# Chnages in the databse structure must be reflected here +tables = ["market", "project", "project_element", "segment"] + +#Tables with the main element of database table. +tablesColumnNames = [] #name of each column of the table +tablesPrimaryKeys = [] #Primary key of each table +tablesForeignKeys = [] #Foreign keys of the table (this is a relational database) + +#Initialise tables wiht information on the server! This will drastically hep reduce server +#Requests jus for table indformations +for table in tables: + buffer = db.getColumnNames(cursorProjects, table) + tablesColumnNames.append(buffer) + + buffer = db.getPrimaryKey(cursorProjects, table) + tablesPrimaryKeys.append(buffer) + + buffer = db.getForeignKeys(cursorProjects, table) + tablesForeignKeys.append(buffer) + + +#Get the tables contained in this database +def getTables(): + return tables + +#Get the foreign keys list of the given table +def getForeignKeys(table): + return(tablesForeignKeys[tables.index(table)]) + +#Get the amount of foreign key of the given table +def getForeignKeyCount(table): + return(len(tablesForeignKeys[tables.index(table)])) + +#Get the index of a foreign key's name contained in the given table +def getForeignKeyIndex(table, keyName): + return(tablesForeignKeys[tables.index(table)].index(keyName)) + +#Get the name of a foreign key's index contained in the given table +def getForeignKeyName(table, keyIndex): + return(tablesForeignKeys[tables.index(table)][keyIndex]) + +#Get the primary key's name of the given table +def getPrimaryKey(table): + return(tablesPrimaryKeys[tables.index(table)]) + +#Get the column Names list of the given table +def getColumnNames(table): + return(tablesColumnNames[tables.index(table)]) + +#Get the amount of column's of the given table +def getColumnCount(table): + return(len(tablesColumnNames[tables.index(table)])) + +#Get the index of a column's name contained in the given table +def getColumnNameIndex(table, columnName): + return(tablesColumnNames[tables.index(table)].index(columnName)) + +#Get the name of a columns's index contained in the given table +def getColumnName(table, columnIndex): + return(tablesColumnNames[tables.index(table)][columnIndex]) + +def printTablesInfo(): + for table in getTables(): + print( "Table: " + table) + print( " - Primary Key : " + getPrimaryKey(table)) + for column in getColumnNames(table): + print( " - Colum: " + column) + for key in getForeignKeys(table): + print( " - Foreign Key : " + key) + +printTablesInfo() + diff --git a/dbUtils/dbMaterials.py b/dbUtils/dbMaterials.py new file mode 100755 index 00000000..af82de53 --- /dev/null +++ b/dbUtils/dbMaterials.py @@ -0,0 +1,78 @@ +import dbCommands as db + +#Connect to the database +cursor = db.connect("minibase_materials") + +# This list must represent what the database contains as tables. +# Chnages in the databse structure must be reflected here +tables = ["classification", "packaging", "physical", "product"] + +#Tables with the main element of database table. +tablesColumnNames = [] #name of each column of the table +tablesPrimaryKeys = [] #Primary key of each table +tablesForeignKeys = [] #Foreign keys of the table (this is a relational database) + +#Initialise tables wiht information on the server! This will drastically hep reduce server +#Requests jus for table indformations +for table in tables: + buffer = db.getColumnNames(cursor, table) + tablesColumnNames.append(buffer) + + buffer = db.getPrimaryKey(cursor, table) + tablesPrimaryKeys.append(buffer) + + buffer = db.getForeignKeys(cursor, table) + tablesForeignKeys.append(buffer) + + +#Get the tables contained in this database +def getTables(): + return tables + +#Get the foreign keys list of the given table +def getForeignKeys(table): + return(tablesForeignKeys[tables.index(table)]) + +#Get the amount of foreign key of the given table +def getForeignKeyCount(table): + return(len(tablesForeignKeys[tables.index(table)])) + +#Get the index of a foreign key's name contained in the given table +def getForeignKeyIndex(table, keyName): + return(tablesForeignKeys[tables.index(table)].index(keyName)) + +#Get the name of a foreign key's index contained in the given table +def getForeignKeyName(table, keyIndex): + return(tablesForeignKeys[tables.index(table)][keyIndex]) + +#Get the primary key's name of the given table +def getPrimaryKey(table): + return(tablesPrimaryKeys[tables.index(table)]) + +#Get the column Names list of the given table +def getColumnNames(table): + return(tablesColumnNames[tables.index(table)]) + +#Get the amount of column's of the given table +def getColumnCount(table): + return(len(tablesColumnNames[tables.index(table)])) + +#Get the index of a column's name contained in the given table +def getColumnNameIndex(table, columnName): + return(tablesColumnNames[tables.index(table)].index(columnName)) + +#Get the name of a columns's index contained in the given table +def getColumnName(table, columnIndex): + return(tablesColumnNames[tables.index(table)][columnIndex]) + +def printTablesInfo(): + for table in getTables(): + print( "Table: " + table) + print( " - Primary Key : " + getPrimaryKey(table)) + for column in getColumnNames(table): + print( " - Colum: " + column) + for key in getForeignKeys(table): + print( " - Foreign Key : " + key) + +printTablesInfo() + diff --git a/dbUtils/dbProjects.py b/dbUtils/dbProjects.py new file mode 100755 index 00000000..b9e61de7 --- /dev/null +++ b/dbUtils/dbProjects.py @@ -0,0 +1,78 @@ +import dbCommands as db + +#Connect to the database +cursor = db.connect("minibase_projects") + +# This list must represent what the database contains as tables. +# Chnages in the databse structure must be reflected here +tables = ["market", "project", "project_element", "segment"] + +#Tables with the main element of database table. +tablesColumnNames = [] #name of each column of the table +tablesPrimaryKeys = [] #Primary key of each table +tablesForeignKeys = [] #Foreign keys of the table (this is a relational database) + +#Initialise tables wiht information on the server! This will drastically hep reduce server +#Requests jus for table indformations +for table in tables: + buffer = db.getColumnNames(cursor, table) + tablesColumnNames.append(buffer) + + buffer = db.getPrimaryKey(cursor, table) + tablesPrimaryKeys.append(buffer) + + buffer = db.getForeignKeys(cursor, table) + tablesForeignKeys.append(buffer) + + +#Get the tables contained in this database +def getTables(): + return tables + +#Get the foreign keys list of the given table +def getForeignKeys(table): + return(tablesForeignKeys[tables.index(table)]) + +#Get the amount of foreign key of the given table +def getForeignKeyCount(table): + return(len(tablesForeignKeys[tables.index(table)])) + +#Get the index of a foreign key's name contained in the given table +def getForeignKeyIndex(table, keyName): + return(tablesForeignKeys[tables.index(table)].index(keyName)) + +#Get the name of a foreign key's index contained in the given table +def getForeignKeyName(table, keyIndex): + return(tablesForeignKeys[tables.index(table)][keyIndex]) + +#Get the primary key's name of the given table +def getPrimaryKey(table): + return(tablesPrimaryKeys[tables.index(table)]) + +#Get the column Names list of the given table +def getColumnNames(table): + return(tablesColumnNames[tables.index(table)]) + +#Get the amount of column's of the given table +def getColumnCount(table): + return(len(tablesColumnNames[tables.index(table)])) + +#Get the index of a column's name contained in the given table +def getColumnNameIndex(table, columnName): + return(tablesColumnNames[tables.index(table)].index(columnName)) + +#Get the name of a columns's index contained in the given table +def getColumnName(table, columnIndex): + return(tablesColumnNames[tables.index(table)][columnIndex]) + +def printTablesInfo(): + for table in getTables(): + print( "Table: " + table) + print( " - Primary Key : " + getPrimaryKey(table)) + for column in getColumnNames(table): + print( " - Colum: " + column) + for key in getForeignKeys(table): + print( " - Foreign Key : " + key) + +printTablesInfo() + diff --git a/dbUtils/dbRelationships.py b/dbUtils/dbRelationships.py new file mode 100755 index 00000000..7c03d2d2 --- /dev/null +++ b/dbUtils/dbRelationships.py @@ -0,0 +1,78 @@ +import dbCommands as db + +#Connect to the database +cursor = db.connect("minibase_relationships") + +# This list must represent what the database contains as tables. +# Chnages in the databse structure must be reflected here +tables = ["company", "company_role", "person", "person_role"] + +#Tables with the main element of database table. +tablesColumnNames = [] #name of each column of the table +tablesPrimaryKeys = [] #Primary key of each table +tablesForeignKeys = [] #Foreign keys of the table (this is a relational database) + +#Initialise tables wiht information on the server! This will drastically hep reduce server +#Requests jus for table indformations +for table in tables: + buffer = db.getColumnNames(cursor, table) + tablesColumnNames.append(buffer) + + buffer = db.getPrimaryKey(cursor, table) + tablesPrimaryKeys.append(buffer) + + buffer = db.getForeignKeys(cursor, table) + tablesForeignKeys.append(buffer) + + +#Get the tables contained in this database +def getTables(): + return tables + +#Get the foreign keys list of the given table +def getForeignKeys(table): + return(tablesForeignKeys[tables.index(table)]) + +#Get the amount of foreign key of the given table +def getForeignKeyCount(table): + return(len(tablesForeignKeys[tables.index(table)])) + +#Get the index of a foreign key's name contained in the given table +def getForeignKeyIndex(table, keyName): + return(tablesForeignKeys[tables.index(table)].index(keyName)) + +#Get the name of a foreign key's index contained in the given table +def getForeignKeyName(table, keyIndex): + return(tablesForeignKeys[tables.index(table)][keyIndex]) + +#Get the primary key's name of the given table +def getPrimaryKey(table): + return(tablesPrimaryKeys[tables.index(table)]) + +#Get the column Names list of the given table +def getColumnNames(table): + return(tablesColumnNames[tables.index(table)]) + +#Get the amount of column's of the given table +def getColumnCount(table): + return(len(tablesColumnNames[tables.index(table)])) + +#Get the index of a column's name contained in the given table +def getColumnNameIndex(table, columnName): + return(tablesColumnNames[tables.index(table)].index(columnName)) + +#Get the name of a columns's index contained in the given table +def getColumnName(table, columnIndex): + return(tablesColumnNames[tables.index(table)][columnIndex]) + +def printTablesInfo(): + for table in getTables(): + print( "Table: " + table) + print( " - Primary Key : " + getPrimaryKey(table)) + for column in getColumnNames(table): + print( " - Colum: " + column) + for key in getForeignKeys(table): + print( " - Foreign Key : " + key) + +printTablesInfo() + diff --git a/learning/rust/flowControl/Cargo.toml b/old/learning/rust/flowControl/Cargo.toml similarity index 100% rename from learning/rust/flowControl/Cargo.toml rename to old/learning/rust/flowControl/Cargo.toml diff --git a/learning/rust/flowControl/src/main.rs b/old/learning/rust/flowControl/src/main.rs similarity index 100% rename from learning/rust/flowControl/src/main.rs rename to old/learning/rust/flowControl/src/main.rs diff --git a/learning/rust/functions/Cargo.toml b/old/learning/rust/functions/Cargo.toml similarity index 100% rename from learning/rust/functions/Cargo.toml rename to old/learning/rust/functions/Cargo.toml diff --git a/learning/rust/functions/src/main.rs b/old/learning/rust/functions/src/main.rs similarity index 100% rename from learning/rust/functions/src/main.rs rename to old/learning/rust/functions/src/main.rs diff --git a/learning/rust/guessing_game/Cargo.toml b/old/learning/rust/guessing_game/Cargo.toml similarity index 100% rename from learning/rust/guessing_game/Cargo.toml rename to old/learning/rust/guessing_game/Cargo.toml diff --git a/learning/rust/guessing_game/src/main.rs b/old/learning/rust/guessing_game/src/main.rs similarity index 100% rename from learning/rust/guessing_game/src/main.rs rename to old/learning/rust/guessing_game/src/main.rs diff --git a/learning/rust/ownership/Cargo.toml b/old/learning/rust/ownership/Cargo.toml similarity index 100% rename from learning/rust/ownership/Cargo.toml rename to old/learning/rust/ownership/Cargo.toml diff --git a/learning/rust/ownership/src/main.rs b/old/learning/rust/ownership/src/main.rs similarity index 100% rename from learning/rust/ownership/src/main.rs rename to old/learning/rust/ownership/src/main.rs diff --git a/learning/rust/varibales/Cargo.toml b/old/learning/rust/varibales/Cargo.toml similarity index 100% rename from learning/rust/varibales/Cargo.toml rename to old/learning/rust/varibales/Cargo.toml diff --git a/learning/rust/varibales/src/main.rs b/old/learning/rust/varibales/src/main.rs similarity index 100% rename from learning/rust/varibales/src/main.rs rename to old/learning/rust/varibales/src/main.rs diff --git a/sql/databaseSetup/create_database.sql b/old/sql/databaseSetup/create_database.sql similarity index 100% rename from sql/databaseSetup/create_database.sql rename to old/sql/databaseSetup/create_database.sql diff --git a/sql/lists/.~lock.ifx_price.xlsx# b/old/sql/lists/.~lock.ifx_price.xlsx# similarity index 100% rename from sql/lists/.~lock.ifx_price.xlsx# rename to old/sql/lists/.~lock.ifx_price.xlsx# diff --git a/sql/lists/ifx_price.csv b/old/sql/lists/ifx_price.csv similarity index 100% rename from sql/lists/ifx_price.csv rename to old/sql/lists/ifx_price.csv diff --git a/sql/lists/ifx_price.xlsx b/old/sql/lists/ifx_price.xlsx similarity index 100% rename from sql/lists/ifx_price.xlsx rename to old/sql/lists/ifx_price.xlsx diff --git a/sql/lists/ifx_price_csv.csv b/old/sql/lists/ifx_price_csv.csv similarity index 100% rename from sql/lists/ifx_price_csv.csv rename to old/sql/lists/ifx_price_csv.csv diff --git a/sql/lists/ifx_prices.csv b/old/sql/lists/ifx_prices.csv similarity index 100% rename from sql/lists/ifx_prices.csv rename to old/sql/lists/ifx_prices.csv diff --git a/sql/load_csv.sh b/old/sql/load_csv.sh similarity index 100% rename from sql/load_csv.sh rename to old/sql/load_csv.sh diff --git a/sql/maria_cmd.sh b/old/sql/maria_cmd.sh similarity index 100% rename from sql/maria_cmd.sh rename to old/sql/maria_cmd.sh diff --git a/sql/maria_db_sql.sh b/old/sql/maria_db_sql.sh similarity index 100% rename from sql/maria_db_sql.sh rename to old/sql/maria_db_sql.sh diff --git a/sql/maria_ex_sql.sh b/old/sql/maria_ex_sql.sh similarity index 100% rename from sql/maria_ex_sql.sh rename to old/sql/maria_ex_sql.sh diff --git a/sql/output.csv b/old/sql/output.csv similarity index 100% rename from sql/output.csv rename to old/sql/output.csv diff --git a/sql/parser.sh b/old/sql/parser.sh similarity index 100% rename from sql/parser.sh rename to old/sql/parser.sh diff --git a/sql/sent_csv.sh b/old/sql/sent_csv.sh similarity index 100% rename from sql/sent_csv.sh rename to old/sql/sent_csv.sh diff --git a/test/output.csv b/old/test/output.csv similarity index 100% rename from test/output.csv rename to old/test/output.csv diff --git a/tkinter/address_book.db b/old/tkinter/address_book.db similarity index 100% rename from tkinter/address_book.db rename to old/tkinter/address_book.db diff --git a/tkinter/database.py b/old/tkinter/database.py similarity index 100% rename from tkinter/database.py rename to old/tkinter/database.py diff --git a/tkinter/icons/icon.ico b/old/tkinter/icons/icon.ico similarity index 100% rename from tkinter/icons/icon.ico rename to old/tkinter/icons/icon.ico diff --git a/tkinter/icons/rocket-64x64.png b/old/tkinter/icons/rocket-64x64.png similarity index 100% rename from tkinter/icons/rocket-64x64.png rename to old/tkinter/icons/rocket-64x64.png diff --git a/tkinter/learning/calculator.py b/old/tkinter/learning/calculator.py similarity index 100% rename from tkinter/learning/calculator.py rename to old/tkinter/learning/calculator.py diff --git a/tkinter/learning/example.py b/old/tkinter/learning/example.py similarity index 100% rename from tkinter/learning/example.py rename to old/tkinter/learning/example.py diff --git a/tkinter/learning/main.py b/old/tkinter/learning/main.py similarity index 100% rename from tkinter/learning/main.py rename to old/tkinter/learning/main.py diff --git a/tkinter/mysql.py b/old/tkinter/mysql.py similarity index 100% rename from tkinter/mysql.py rename to old/tkinter/mysql.py diff --git a/tkinter/setup/setupEnv.sh b/old/tkinter/setup/setupEnv.sh similarity index 100% rename from tkinter/setup/setupEnv.sh rename to old/tkinter/setup/setupEnv.sh