Skip to content

strabo231/querycraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test QueryCraft

QueryCraft - SQL Query Builder

Build SQL queries without the syntax headaches! QueryCraft generates clean, correct SQL from simple commands.

Why QueryCraft?

The Problem: SQL syntax is annoying

  • Easy to make mistakes
  • Hard to remember exact syntax
  • WHERE vs HAVING? JOIN vs LEFT JOIN?
  • Forgetting semicolons, quotes, commas

The Solution: Build queries visually

  • No syntax errors
  • Clear, readable output
  • Learn SQL by seeing examples
  • Templates for common patterns

Installation

curl -sSL https://raw.githubusercontent.com/strabo231/querycraft/main/install.sh | bash

Quick Start

# SELECT query
querycraft select users --where "age > 25" --order-by name

# INSERT query
querycraft insert users --columns "name,email" --values "'John','j@example.com'"

# UPDATE query
querycraft update users --set "status='active'" --where "id=5"

# Show templates
querycraft templates

Commands

select <table>           Build SELECT query
insert <table>           Build INSERT query
update <table>           Build UPDATE query
delete <table>           Build DELETE query
templates                Show common patterns
explain <query>          Understand a query
validate <query>         Check for errors
save <name> <query>      Save for later

Features

🎯 No syntax errors - Generated SQL is always valid
📝 Templates - Common patterns ready to use
Validation - Catch dangerous queries
🎨 Pretty printing - Formatted, readable output
💡 Explanations - Understand what queries do
💾 Save queries - Reuse complex queries
⚠️ Safety warnings - Alerts for DELETE/UPDATE without WHERE

Examples

Basic SELECT:

querycraft select users
SELECT *
FROM users;

SELECT with conditions:

querycraft select users --columns "name,email" --where "age > 18" --order-by name --limit 10
SELECT name,email
FROM users
WHERE age > 18
ORDER BY name
LIMIT 10;

INSERT:

querycraft insert products --columns "name,price,stock" --values "'Laptop',999.99,50"
INSERT INTO products (name,price,stock) VALUES ('Laptop',999.99,50);

UPDATE (safe):

querycraft update users --set "last_login=NOW()" --where "id=123"
UPDATE users SET last_login=NOW() WHERE id=123;

DELETE (with warning):

querycraft delete logs --where "created_at < '2024-01-01'"
DELETE FROM logs WHERE created_at < '2024-01-01';

Safety Features

Dangerous query detection:

querycraft delete users
⚠ This query will:
  • DELETE FROM table: users
✗ No WHERE clause - will delete ALL rows!

Validation:

querycraft validate "UPDATE users SET status='active'"
✗ UPDATE without WHERE will update ALL rows!
✗ Found 1 potential issues

Query Templates

querycraft templates

Shows patterns for:

  • Basic SELECT
  • SELECT with WHERE
  • SELECT with JOIN
  • INSERT single/multiple rows
  • UPDATE with WHERE
  • DELETE with WHERE
  • COUNT and aggregations
  • GROUP BY
  • LEFT JOIN

Use Cases

Learning SQL:

# See how queries are structured
querycraft select orders --join "customers ON orders.customer_id = customers.id"

Quick queries:

# Build queries faster than typing
querycraft select products --where "price < 100" --order-by price

Avoid mistakes:

# Validation catches errors
querycraft validate "DELETE FROM important_table"
# ✗ No WHERE clause!

Requirements

  • Bash 4.0+

License

MIT License

Author

Sean - @strabo231


Build SQL. Without the pain. 🎯

About

SQL query builder that generates clean, correct SQL from simple commands. No more syntax errors!

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages