Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add files via upload #4

wants to merge 1 commit into from

Conversation

vijvipin
Copy link

Fixed the bug so that primary key is only generated if I define any in the UML using '#'
Otherwise, the code will not generate code for the primary key. Just to highlight the section:

if field and l == "}":
table = False; field = False
if primary: #Vijvipin
print(" PRIMARY KEY (%s)" % ", ".join(primary), end="")
if index:
print(",\n%s" % index[:-2],)
index = ""
print(");\n")
print("GO\n") #Vijvipin
continue

I have done other changes as well to suit my need. So feel free to connect if you need to understand

Fixed the bug so that primary key is only generated  if I define any in the UML using '#'
Otherwise, the code will not generate code for the primary key.
if l.startswith("class"):
table = True; field = False
primary = []; index = ""
# Table names are quoted and lower cased to avoid conflict with a mySQL reserved word
print("CREATE TABLE IF NOT EXISTS `" + i[1].lower() + "` (")
print("CREATE TABLE stg." + i[1].lower() + " (")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't understand the syntax here. What is this stg prefix?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stg is just the schema or the user name in which the table is being created. This was done as we have two layers of tables with same name, same like stg and pub schema in data warehouse systems.

@@ -19,9 +18,8 @@ def strip_html_tags(t):

# A minimal help
def print_usage():
print("Convert PlantUML classes schema into mySQL database creation script")
print("Convert PlantUML classes schema into SQL database creation script")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think the script promise compatibility for mysql only, so I reflected it in this message. I not planned it as a common script for many RDBMS though it could be applied with minor changes to other SQL-based systems.

print('')
print('')
print('####################################################################################################')
print("****************************\t TDH Info Model DB Script")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, could you explain TDH acronym?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TDH can be totally ignored. It is dome term sued in my project, forgot to remove.

if index:
print(",\n%s" % index[:-2],)
index = ""
print(");\n")
print("GO\n") #Vips
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought "go" doesn't work with mySQL as a delimiter by default. Is it really works with mysql without redefining it with delimiter command?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well frankly I changed this script to suite Azure SQL database. So may be if you find suitable you may create a separate branch for this. :)
And Of course #Vips needs to be ignored. This was basically a TAG kind of thing which I added to mark the changes done by me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants