[BE-02] feat(firebir): Conecta ao banco de dados firebird 4.0
This commit is contained in:
parent
18f320622f
commit
5ac6246342
6 changed files with 50628 additions and 49 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"name": "C:/Users/keven/OneDrive/Desktop/Orius/CAIAPONIA.FDB",
|
"name": "C:/Orius/Base/CAIAPONIA.FDB",
|
||||||
"port": 3050,
|
"port": 3050,
|
||||||
"user": "SYSDBA",
|
"user": "SYSDBA",
|
||||||
"password": "302b3c",
|
"password": "master!orius",
|
||||||
"charset": "UTF8",
|
"charset": "UTF8",
|
||||||
"pool" : {
|
"pool" : {
|
||||||
"pre_ping" : "True",
|
"pre_ping" : true,
|
||||||
"size" : 5,
|
"size" : 5,
|
||||||
"max_overflow" :10
|
"max_overflow" :10
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
# core/database/connection_manager.py
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.engine import Engine
|
from sqlalchemy.engine import Engine
|
||||||
|
|
||||||
|
|
@ -12,44 +10,34 @@ class Firebird:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_engine(cls) -> Engine:
|
def get_engine(cls) -> Engine:
|
||||||
|
# Obtem as configurações do arquivo JSON
|
||||||
# Obtem as configurações de banco de dados
|
|
||||||
database = Config.get('database/firebird.json')
|
database = Config.get('database/firebird.json')
|
||||||
|
|
||||||
# Se nao existir engine, cria uma nova
|
# Cria a engine apenas uma vez
|
||||||
if cls._engine is None:
|
if cls._engine is None:
|
||||||
|
|
||||||
# Caminho da conexão com o banco de dados
|
# DSN para o SQLAlchemy usando firebird-driver
|
||||||
dsn = (
|
dsn = (
|
||||||
f"firebird://{database.user}:"
|
f"firebird+firebird://{database.user}:"
|
||||||
f"{database.password}@"
|
f"{database.password}@"
|
||||||
f"{database.host}:"
|
f"{database.host}:"
|
||||||
f"{database.port}/"
|
f"{database.port}/"
|
||||||
f"{database.name}"
|
f"{database.name}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Criação da Engine
|
# Criação da engine SQLAlchemy
|
||||||
cls._engine = create_engine(
|
cls._engine = create_engine(
|
||||||
dsn,
|
dsn,
|
||||||
connect_args={
|
connect_args={"charset": database.charset},
|
||||||
"charset": database.charset,
|
pool_pre_ping=bool(database.pool.pre_ping),
|
||||||
},
|
|
||||||
pool_pre_ping=database.pool.pre_ping,
|
|
||||||
pool_size=database.pool.size,
|
pool_size=database.pool.size,
|
||||||
max_overflow=database.pool.max_overflow
|
max_overflow=database.pool.max_overflow,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Retorna a criação da engine
|
|
||||||
return cls._engine
|
return cls._engine
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dispose(cls):
|
def dispose(cls):
|
||||||
|
|
||||||
# Verifica se existe engine
|
|
||||||
if cls._engine:
|
if cls._engine:
|
||||||
|
|
||||||
# Se existir encerra a conexão
|
|
||||||
cls._engine.dispose()
|
cls._engine.dispose()
|
||||||
|
|
||||||
# Anula a engine
|
|
||||||
cls._engine = None
|
cls._engine = None
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,14 @@ from starlette.middleware.base import BaseHTTPMiddleware
|
||||||
from packages.v1.api import api_router
|
from packages.v1.api import api_router
|
||||||
from packages.v1.system.service.startup_check_service import \
|
from packages.v1.system.service.startup_check_service import \
|
||||||
StartupCheckService
|
StartupCheckService
|
||||||
|
|
||||||
# Importa as configurações globais da aplicação
|
# Importa as configurações globais da aplicação
|
||||||
from core.configs import settings
|
|
||||||
from actions.log.log import Log
|
from actions.log.log import Log
|
||||||
from actions.config.config import Config
|
from actions.config.config import Config
|
||||||
from actions.system.handlers import register_exception_handlers
|
from actions.system.handlers import register_exception_handlers
|
||||||
|
|
||||||
|
config = Config.get('app.json')
|
||||||
|
|
||||||
# Instancia o app FastAPI com um título personalizado
|
# Instancia o app FastAPI com um título personalizado
|
||||||
app = FastAPI(title='SAAS Orius')
|
app = FastAPI(title='SAAS Orius')
|
||||||
|
|
||||||
|
|
@ -73,7 +75,7 @@ async def log_tempo_requisicao(request: Request, call_next):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Inclui as rotas da versão 1 da API com prefixo definido em settings (ex: /api/v1)
|
# Inclui as rotas da versão 1 da API com prefixo definido em settings (ex: /api/v1)
|
||||||
app.include_router(api_router, prefix=settings.API_V1_STR)
|
app.include_router(api_router, prefix=config.url)
|
||||||
|
|
||||||
# Executa o servidor com Uvicorn se este arquivo for executado diretamente
|
# Executa o servidor com Uvicorn se este arquivo for executado diretamente
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,30 @@
|
||||||
annotated-types==0.7.0
|
annotated-types==0.7.0
|
||||||
anyio==4.9.0
|
anyio==4.10.0
|
||||||
asyncpg==0.30.0
|
|
||||||
bcrypt==3.2.0
|
|
||||||
cffi==1.17.1
|
|
||||||
click==8.2.1
|
click==8.2.1
|
||||||
colorama==0.4.6
|
colorama==0.4.6
|
||||||
cryptography==45.0.2
|
|
||||||
dnspython==2.7.0
|
dnspython==2.7.0
|
||||||
ecdsa==0.19.1
|
ecdsa==0.19.1
|
||||||
email_validator==2.2.0
|
email_validator==2.2.0
|
||||||
fastapi==0.115.12
|
fastapi==0.116.1
|
||||||
future==1.0.0
|
firebird-base==2.0.2
|
||||||
greenlet==3.2.2
|
firebird-driver==2.0.2
|
||||||
|
greenlet==3.2.4
|
||||||
h11==0.16.0
|
h11==0.16.0
|
||||||
idna==3.10
|
idna==3.10
|
||||||
mysql-connector-python==9.3.0
|
|
||||||
packaging==25.0
|
packaging==25.0
|
||||||
passlib==1.7.4
|
protobuf==5.29.5
|
||||||
protobuf==5.29.4
|
pyasn1==0.6.1
|
||||||
pyasn1==0.4.8
|
pydantic==2.11.7
|
||||||
pycparser==2.22
|
|
||||||
pydantic==2.11.4
|
|
||||||
pydantic-settings==2.9.1
|
|
||||||
pydantic_core==2.33.2
|
pydantic_core==2.33.2
|
||||||
PyMySQL==1.1.1
|
|
||||||
python-dateutil==2.9.0.post0
|
python-dateutil==2.9.0.post0
|
||||||
python-dotenv==1.1.0
|
python-jose==3.5.0
|
||||||
python-jose==3.4.0
|
|
||||||
python-multipart==0.0.20
|
|
||||||
pytz==2025.2
|
pytz==2025.2
|
||||||
rsa==4.9.1
|
rsa==4.9.1
|
||||||
six==1.17.0
|
six==1.17.0
|
||||||
sniffio==1.3.1
|
sniffio==1.3.1
|
||||||
SQLAlchemy==2.0.41
|
SQLAlchemy==2.0.42
|
||||||
starlette==0.46.2
|
sqlalchemy-firebird==2.1
|
||||||
typing-inspection==0.4.0
|
starlette==0.47.2
|
||||||
typing_extensions==4.13.2
|
typing-inspection==0.4.1
|
||||||
uvicorn==0.34.2
|
typing_extensions==4.14.1
|
||||||
|
uvicorn==0.35.0
|
||||||
|
|
|
||||||
|
|
@ -51,5 +51,60 @@
|
||||||
"storage/temp/validation_exception_handler.json",
|
"storage/temp/validation_exception_handler.json",
|
||||||
"storage/temp/validation_exception_handler.json",
|
"storage/temp/validation_exception_handler.json",
|
||||||
"storage/temp/validation_exception_handler.json",
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
|
"storage/temp/validation_exception_handler.json",
|
||||||
"storage/temp/validation_exception_handler.json"
|
"storage/temp/validation_exception_handler.json"
|
||||||
]
|
]
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue