Skip to content

Commit d40d775

Browse files
committed
Added notebook
1 parent 8ea972b commit d40d775

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,4 @@ python tests/test_runner.py
222222

223223
---
224224

225-
📓 [Try it in a Jupyter notebook](https://raw.githubusercontent.com/viragtripathi/crdb-sql-audit/main/notebooks/demo_crdb_sql_audit.ipynb)
225+
📓 [Try it in a Jupyter notebook](notebooks/demo_crdb_sql_audit.ipynb)

notebooks/demo_crdb_sql_audit.ipynb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,36 @@
88
{
99
"cell_type": "code",
1010
"metadata": {},
11+
"outputs": [],
12+
"execution_count": null,
1113
"source": "# Install the tool (if not already installed in the environment)\n!pip install crdb-sql-audit"
1214
},
1315
{
1416
"cell_type": "code",
1517
"metadata": {},
18+
"outputs": [],
19+
"execution_count": null,
1620
"source": "# Step 1: Load the rules YAML\nimport yaml\n\nwith open(\"rules/test_rules.yaml\") as f:\n rules = yaml.safe_load(f)\n\nprint(f\"\u2705 Loaded {len(rules)} rules\")"
1721
},
1822
{
1923
"cell_type": "code",
2024
"metadata": {},
25+
"outputs": [],
26+
"execution_count": null,
2127
"source": "# Step 2: Load a test log file (SQL lines)\nwith open(\"tests/sample_logs/basic_pg_chunk.log\") as f:\n raw_lines = [line.strip() for line in f if line.strip()]\n\nprint(f\"\u2705 Loaded {len(raw_lines)} lines\")"
2228
},
2329
{
2430
"cell_type": "code",
2531
"metadata": {},
32+
"outputs": [],
33+
"execution_count": null,
2634
"source": "# Step 3: Use rule engine directly\nimport re\nfrom crdb_sql_audit.rules_engine import apply_rules\n\nall_matches = []\nfor line in raw_lines:\n matches = apply_rules(line, rules)\n all_matches.extend(matches)\n\nprint(f\"\ud83d\udea8 Total matches: {len(all_matches)}\")"
2735
},
2836
{
2937
"cell_type": "code",
3038
"metadata": {},
39+
"outputs": [],
40+
"execution_count": null,
3141
"source": "# Step 4: Visualize results\nimport pandas as pd\n\nif all_matches:\n df = pd.DataFrame(all_matches)\n display(df[['Rule_ID', 'SQL_Type', 'Issue', 'Example']])\nelse:\n print(\"No matches found.\")"
3242
}
3343
],
@@ -43,5 +53,5 @@
4353
}
4454
},
4555
"nbformat": 4,
46-
"nbformat_minor": 2
56+
"nbformat_minor": 5
4757
}

0 commit comments

Comments
 (0)