1- # 🧪 GenAI-SQL CLI Usage Guide
1+ # GenAI-SQL CLI Usage Guide
22
33This guide provides examples and explanations for using the ` GenAI-SQL ` CLI (` app.py ` ) with various task and execution options.
44
55---
66
7- ## 🧼 Clean and Save to a New File
7+ ## Clean and Save to a New File
88
99``` bash
1010python app.py --task=comment --path=example.sql --sanitize --output=cleaned_example.sql
1111```
1212
13- ### 🔍 What It Does:
13+ ### What It Does:
1414- ** Task** : ` comment ` — adds header and inline documentation to ` example.sql ` .
1515- ** ` --sanitize ` ** : Removes extra GPT explanations or markdown.
1616- ** ` --output=... ` ** : Writes the updated SQL to ` cleaned_example.sql ` instead of overwriting the original file.
1717
1818---
1919
20- ## 🔍 Preview Refactored Query (No File Overwrite)
20+ ## Preview Refactored Query (No File Overwrite)
2121
2222``` bash
2323python app.py --task=refactor --path=query.sql --dry-run
2424```
2525
26- ### 🔍 What It Does:
26+ ### What It Does:
2727- ** Task** : ` refactor ` — rewrites legacy SQL to modern best practices (CTEs, clean formatting).
2828- ** ` --dry-run ` ** : Only shows the result in the terminal, without modifying ` query.sql ` .
2929
3030---
3131
32- ## 🗃️ Process All ` .sql ` Files in a Folder (With Backups)
32+ ## Process All ` .sql ` Files in a Folder (With Backups)
3333
3434``` bash
3535python app.py --task=analyze --path=./sql_scripts --recursive --backup
3636```
3737
38- ### 🔍 What It Does:
38+ ### What It Does:
3939- ** Task** : ` analyze ` — finds inefficiencies and suggests performance improvements.
4040- ** ` --recursive ` ** : Processes all ` .sql ` files in the folder and subfolders.
4141- ** ` --backup ` ** : Creates ` .bak ` files before overwriting each script.
4242
4343---
4444
45- ## 🔐 Run Security Audit and Stage for Git
45+ ## Run Security Audit and Stage for Git
4646
4747``` bash
4848python app.py --task=audit --path=query.sql --git
4949```
5050
51- ### 🔍 What It Does:
51+ ### What It Does:
5252- ** Task** : ` audit ` — scans ` query.sql ` for:
5353 - SQL injection risk
5454 - PHI/PII exposure
@@ -58,37 +58,37 @@ python app.py --task=audit --path=query.sql --git
5858
5959---
6060
61- ## 🗣️ Explain Query Logic in Natural Language
61+ ## Explain Query Logic in Natural Language
6262
6363``` bash
6464python app.py --task=explain --path=query.sql --output=explanation.txt
6565```
6666
67- ### 🔍 What It Does:
67+ ### What It Does:
6868- ** Task** : ` explain ` — translates the logic of ` query.sql ` into a natural language explanation, making it easier to understand complex queries.
6969- ** ` --output=... ` ** : Saves the explanation to ` explanation.txt ` .
7070
7171---
7272
73- ## 🧪 Generate Unit Test Ideas for SQL Logic
73+ ## Generate Unit Test Ideas for SQL Logic
7474
7575``` bash
7676python app.py --task=test --path=query.sql --output=test_ideas.txt
7777```
7878
79- ### 🔍 What It Does:
79+ ### What It Does:
8080- ** Task** : ` test ` — analyzes ` query.sql ` and generates unit test ideas to validate its logic.
8181- ** ` --output=... ` ** : Saves the generated test ideas to ` test_ideas.txt ` .
8282
8383---
8484
85- ## 📊 Benchmark SQL Query Performance
85+ ## Benchmark SQL Query Performance
8686
8787``` bash
8888python app.py --task=benchmark --path=example.sql --dry-run
8989```
9090
91- ### 🔍 What It Does:
91+ ### What It Does:
9292- ** Task** : ` benchmark ` — simulates query execution to measure performance metrics like:
9393 - Execution time
9494 - Index usage
@@ -97,19 +97,19 @@ python app.py --task=benchmark --path=example.sql --dry-run
9797
9898---
9999
100- ## 📈 Visualize Query Execution Plan
100+ ## Visualize Query Execution Plan
101101
102102``` bash
103103python app.py --task=visualize --path=query.sql --output=query_plan.png
104104```
105105
106- ### 🔍 What It Does:
106+ ### What It Does:
107107- ** Task** : ` visualize ` — generates a graphical representation of the query execution plan.
108108- ** ` --output=... ` ** : Saves the visualization as ` query_plan.png ` .
109109
110110---
111111
112- ## 🚀 Convert Natural Language to SQL
112+ ## Convert Natural Language to SQL
113113
114114### Inline Natural Language Query
115115
@@ -123,14 +123,14 @@ python app.py --task=nl_to_sql --path="list all patients diagnosed with diabetes
123123python app.py --task=nl_to_sql --path=nl_query.txt --sql_dialect=" T-SQL" --schema_path=" schema/HealthClaimsDW.json" --output=generated_query.sql
124124```
125125
126- ### 🔍 What It Does:
126+ ### What It Does:
127127- ** Task** : ` nl_to_sql ` — converts plain language queries into SQL using the specified schema.
128128- ** ` --sql_dialect=... ` ** : Specifies the SQL dialect (e.g., T-SQL, PostgreSQL).
129129- ** ` --schema_path=... ` ** : Points to the schema for generating valid SQL.
130130
131131---
132132
133- ## 🧠 Tip: Combine Flags
133+ ## Tip: Combine Flags
134134
135135You can combine options for more control:
136136
@@ -146,13 +146,13 @@ python app.py --task=comment --path=query.sql --sanitize --output=query_commente
146146
147147---
148148
149- ## 🔒 Mask Sensitive Data in SQL Queries
149+ ## Mask Sensitive Data in SQL Queries
150150
151151``` bash
152152python app.py --task=mask --path=example.sql --output=masked_example.sql
153153```
154154
155- ### 🔍 What It Does:
155+ ### What It Does:
156156- ** Task** : ` mask ` — Automatically identifies and masks sensitive data such as:
157157 - Email addresses.
158158 - Phone numbers.
@@ -163,21 +163,21 @@ python app.py --task=mask --path=example.sql --output=masked_example.sql
163163
164164---
165165
166- ## 🛠️ Enforce SQL Style Guide
166+ ## Enforce SQL Style Guide
167167
168168``` bash
169169python app.py --task=style_enforce --path=example.sql --sql_dialect=PostgreSQL --output=styled_example.sql
170170```
171171
172- ### 🧑🏫 What It Does:
172+ ### What It Does:
173173- ** Task** : ` style_enforce ` — Enforces SQL coding standards dynamically using AI.
174174- ** ` --sql_dialect=... ` ** : Specifies the SQL dialect (e.g., PostgreSQL, T-SQL).
175175- ** ` --output=... ` ** : Writes the styled SQL to a new file.
176176- ** ` --dry-run ` ** : Displays the AI-styled SQL without saving the changes.
177177
178178---
179179
180- ## 🔧 Available Tasks
180+ ## Available Tasks
181181
182182| Task | Description |
183183| ------------| ----------------------------------------------|
@@ -195,7 +195,7 @@ python app.py --task=style_enforce --path=example.sql --sql_dialect=PostgreSQL -
195195
196196---
197197
198- ## 📂 Example Directory Setup
198+ ## Example Directory Setup
199199
200200```
201201project-root/
@@ -212,7 +212,7 @@ project-root/
212212
213213---
214214
215- ## 📄 License
215+ ## License
216216
217217See the [ MIT License] ( ./LICENSE ) for usage terms.
218218
0 commit comments