Skip to content
Advertisement

Auto Generating SQL Scripts based on User Input using Flask, python

Problem: There is an arduous update script we run for work. It takes a lot of time to update because of security issues. We want to make sure we have edited the update script correctly/want to avoid all permission issues.

Solution: Using Flask as a front end gui to eliminate the possibility for adding the wrong value. The Flask app will guarantee correct placement of inputs into the update script by auto generating the script, so we can just copy and paste into SSMS.


The current problem I am having is aesthetics. I was able to generate a flask app using user inputs and exports a SQL script. The problem is, the sql looks horrible, here is an example of the output: enter image description here


Ideally the output would be multi-line, like all current SQL scripts:

Below are my files:




I also uploaded to github: https://github.com/jpf5046/sqlflask

Ask: Is there a better way to create a text output with multi-line via flask?

Advertisement

Answer

By default, HTML ignores extra space, such as line endings. If you want to display the query exactly like you generate it, use <pre>:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement