SGBD/main.py

38 lines
890 B
Python
Raw Normal View History

2023-11-24 01:25:20 +00:00
import os
from table import Table
from sql import SQL
def main():
print("Bem vindo ao SGBD")
print("Digite a pasta onde está os arquivos CSV:")
#csv_folder = input()
csv_folder = "/mnt/c/Users/jose/Desktop/jcSQL-main/source"
tables = {}
# get all csv files in the folder
for file in os.listdir(csv_folder):
if file.endswith(".csv"):
table_name = file.split(".")[0]
table = Table(table_name)
table.load_from_csv(f"{csv_folder}/{file}")
tables[table_name] = table
print("Tabelas carregadas:")
print(tables.keys())
while True:
print("Digite a query [0 para sair]:")
query = input()
if query == "0":
break
sql = SQL(tables, query)
sql.execute()
2023-11-24 01:38:46 +00:00
print()
2023-11-24 01:25:20 +00:00
if __name__ == "__main__":
main()