Skip to content

Latest commit

 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Generate SQL for creating SQLite tables

How to run:

  1. Clone this repo.
  2. Navigate to the root folder and in it, create the in.txt file.
  3. Fill in the in.txt file while followingn the rules for naming arguments.
    Example:

    TableName1 column_name1 colum_name2 keyTableName3_id
    TableName2
    TableName3 column_name1 TableName1_id column_name2
    TableName4 keykey_name1

  4. Run main.py.

After running:

The main.py script will create sorted-in.txt, create-db.sql and log.txt file in the root folder.
Navigate to the create-db.sql file to view the newly generated SQL.
Additionally, you can now check the sorted-in.txt file. It contains the sorted contents of the in.txt file.

Arguments naming

  • table name arguments:
    Every line must start with one and contain only one. These arguments must be capitalized and can contain small and capital letters, as well as digits.

  • column arguments:
    They can contain small letters, digits and '_' symbols. They represent the column name of the table, and will be assigned an INTEGER data type in the table.

  • foreign key arguments:
    These arguments must end with a "_id" suffix. The part before the "_id" should reference an existing table, and follow the naiming rules for table name arguments.

  • primary/foreign key arguments:
    A primary/foreign key argument must start with a "key" prefix.

Note Before Using

  • If table name argument isn't capitalized, the script will do it automatically. Also, it will remove any '_' characters from it as well.
  • If column argument contains any capital letters, running the script will replace them with their lower case counterparts.
  • Part of the foreign key argument before the "_id" will be treated as if it was a table name argument.
  • If primary/foreign key argument represents a column name, the part followinf a "key" prefix will be treated as if it was a column argument. And if it represents a foreign key, it's post "key" part would be treated as if it was a foreign key argument.

These changes will be present in both the create-db.sql file and the sorted-in.txt file.
Check the log.txt file for the verbose explanations on these and other user mistakes, and for the script failures.


About

SQLGenerator

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages