RandomDBGenerator/pythonProject/main.py
Sebastian Böckelmann ff967a4852 Parse Foreign Keys
2024-04-17 18:01:54 +02:00

30 lines
796 B
Python

# This is a sample Python script.
from sqlparse import SQLParser
from sqlgenerator import SQLGenerator
# Press Umschalt+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def main():
sql_tables = SQLParser.parse_sql_file("schema.sql")
inserts = []
for table in sql_tables:
print(table.foreign_keys)
for i in range(0, 5):
inserts.append(SQLGenerator.generate_random_insert(table))
with open("inserts.sql", "w") as file:
for insert in inserts:
file.write(insert + "\n")
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
main()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/