RandomDBGenerator/pythonProject/main.py

29 lines
762 B
Python
Raw Normal View History

# 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:
2024-04-17 16:22:16 +02:00
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/