Skip to content

Commit 5afece4

Browse files
committed
Initial commit
0 parents  commit 5afece4

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Dependency directories (remove the comment below to include it)
15+
# vendor/

LICENSE.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2025 Michael Douglas
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# SQL Query Builder - Automatizador de Queries Multi-Database
2+
3+
[![Go Version](https://img.shields.io/badge/Go-1.20+-00ADD8?style=flat&logo=go)](https://golang.org/doc/go1.20)
4+
[![Python Version](https://img.shields.io/badge/Python-3.8+-yellow?style=flat&logo=python)](https://www.python.org/downloads/)
5+
[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
6+
7+
Um sistema robusto para automatizar a construção e execução de queries SQL em diferentes bancos de dados, com suporte especial para sistemas legados.
8+
O projeto utiliza Python (Flask/SQLAlchemy) no backend e Go no frontend.
9+
10+
## 📋 Índice
11+
12+
- [Características](#características)
13+
- [Requisitos](#requisitos)
14+
- [Instalação](#instalação)
15+
- [Configuração](#configuração)
16+
- [Uso](#uso)
17+
- [Exemplos](#exemplos)
18+
- [Contribuição](#contribuição)
19+
- [Licença](#licença)
20+
21+
## ✨ Características
22+
23+
### Backend (Python)
24+
- Suporte multi-database (MySQL, PostgreSQL, Oracle, SQL Server)
25+
- Construção dinâmica de queries com múltiplos JOINs
26+
- Pool de conexões para melhor performance
27+
- Tratamento robusto de erros
28+
- Logging configurável
29+
- Validação de dados via dataclasses
30+
- Suporte a queries complexas (WHERE, GROUP BY, ORDER BY, LIMIT)
31+
32+
### Frontend (Go)
33+
- Interface tipo-segura para configuração de queries
34+
- Timeout configurável para requisições
35+
- Tratamento elegante de erros
36+
- Formatação automática dos resultados
37+
38+
## 📦 Requisitos
39+
40+
### Backend
41+
- Python 3.8+
42+
- Flask
43+
- SQLAlchemy
44+
- Drivers de banco de dados específicos:
45+
- MySQL: `pymysql`
46+
- PostgreSQL: `psycopg2-binary`
47+
- Oracle: `cx-oracle`
48+
- SQL Server: `pyodbc`
49+
50+
### Frontend
51+
- Go 1.20+
52+
- Sem dependências externas além da biblioteca padrão
53+
54+
55+
## 🚀 Instalação
56+
57+
1. Clone o repositório:
58+
```bash
59+
git clone https://github.com/bulletdev/sql-query-builder.git
60+
cd sql-query-builder
61+
```
62+
63+
2. Configure o ambiente virtual Python e instale as dependências:
64+
```bash
65+
cd backend
66+
python -m venv venv
67+
source venv/bin/activate
68+
pip install -r requirements.txt
69+
```
70+
>> No Windows:
71+
72+
```bash
73+
cd backend
74+
python -m venv venv
75+
source venv\Scripts\activate
76+
pip install -r requirements.txt
77+
```
78+
79+
3. Configure o ambiente Go:
80+
```bash
81+
cd ../frontend
82+
go mod tidy
83+
```
84+
85+
## ⚙️ Configuração
86+
87+
1. Copie o arquivo de configuração de exemplo:
88+
```bash
89+
cp backend/config.yml.example backend/config.yml
90+
```
91+
92+
2. Edite `config.yml` com suas configurações de banco de dados:
93+
```yaml
94+
databases:
95+
mysql:
96+
host: localhost
97+
port: 3306
98+
pool_size: 5
99+
timeout: 30
100+
oracle:
101+
host: localhost
102+
port: 1521
103+
pool_size: 5
104+
timeout: 30
105+
```
106+
107+
## 💻 Uso
108+
109+
1. Inicie o backend:
110+
```bash
111+
cd backend
112+
python src/app.py
113+
```
114+
115+
2. Em outro terminal, execute o frontend:
116+
```bash
117+
cd frontend
118+
go run cmd/main.go
119+
```
120+
121+
## 📝 Exemplos
122+
123+
### Consulta básica com JOIN (Go)
124+
```go
125+
config := QueryConfig{
126+
DbType: "mysql",
127+
MainTable: "TGFCAB",
128+
Columns: []string{"TGFCAB.NUNOTA", "TGFPAR.NOMEPARC"},
129+
Joins: []JoinCondition{
130+
{
131+
Table: "TGFPAR",
132+
LeftColumn: "CODPARC",
133+
RightColumn: "CODPARC",
134+
JoinType: "left",
135+
},
136+
},
137+
}
138+
```
139+
140+
### Consulta com condições e ordenação (Python)
141+
```python
142+
query_config = QueryConfig(
143+
db_type="oracle",
144+
main_table="TGFCAB",
145+
columns=["NUNOTA", "DTNEG"],
146+
conditions=[{"expression": "DTNEG >= '2024-01-01'"}],
147+
order_by=["DTNEG DESC"],
148+
limit=100
149+
)
150+
```
151+
152+
## 🤝 Contribuição
153+
154+
1. Faça um Fork do projeto
155+
2. Crie sua Feature Branch (`git checkout -b feature/AmazingFeature`)
156+
3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
157+
4. Push para a Branch (`git push origin feature/AmazingFeature`)
158+
5. Abra um Pull Request
159+
160+
## 📄 Licença
161+
162+
Este projeto está licenciado sob a Licença MIT - veja o arquivo [LICENSE](LICENSE) para detalhes.

0 commit comments

Comments
 (0)