https://github.com/thecoderadi/query-extractor
https://github.com/thecoderadi/query-extractor
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/thecoderadi/query-extractor
- Owner: TheCoderAdi
- License: mit
- Created: 2025-09-02T17:33:39.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-09-07T14:30:45.000Z (8 months ago)
- Last Synced: 2025-09-07T16:25:49.133Z (8 months ago)
- Language: JavaScript
- Size: 167 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Query Extractor VS Code Extension
A simple VS Code extension to **extract variables** from SQL queries and copy them to your clipboard.
## ✨ Features
- Extracts variables of the form `${variableName}` from SQL queries.
- Ignores comments (`--` and `/* */`) by default.
- Works for both:
- Whole `.sql` files
- Selected text inside any file
- Automatically copies the found variables as a comma-separated list to your clipboard.
- Shows a notification with the count of variables copied.
---
## 🚀 Usage
1. Open a `.sql` file or select a SQL query snippet.
2. Run the command **`Query Extractor: Extract Variables`**:
- Open **Command Palette** (`Ctrl+Shift+P` / `Cmd+Shift+P` on macOS).
- Search for **"Query Extractor: Extract Variables"**.
3. If variables are found:
- They are copied to your clipboard.
- You’ll see a message like `Copied 3 variables to clipboard`.
---
## 📦 Example
```sql
-- Sample SQL
SELECT *
FROM users
WHERE id = ${userId}
AND status = ${status}
AND role = ${userRole};
```
**Extracted Variables:**
```
status, userId, userRole
```
---
## ⚙️ Installation (Local Dev)
1. Clone or download this repository.
2. Run `npm install` to install dependencies.
3. Open the project in VS Code.
4. Press `F5` to launch a new VS Code window with the extension loaded.
5. Run the command from the Command Palette.
---
## 🛠️ Development Notes
- Variables are matched using the regex:
```regex
(?