diff --git a/config/app.json b/config/app.json index 31e1959..7e9f5cb 100644 --- a/config/app.json +++ b/config/app.json @@ -1,6 +1,6 @@ { "state" : "go", - "url": "/api/v1", + "url": "", "log": { "request": { "name": "request.json", diff --git a/config/database/postgres.json b/config/database/postgres.json index 62ea64f..13b02bf 100644 --- a/config/database/postgres.json +++ b/config/database/postgres.json @@ -1,9 +1,9 @@ { "host": "localhost", "port": 5432, - "name": "mirror", + "name": "postgres", "user": "postgres", - "password": "root", + "password": "mirrorapidb", "charset": "UTF8", "pool": { "pre_ping": true, diff --git a/mirrorApi.code-workspace b/mirrorApi.code-workspace new file mode 100644 index 0000000..66862e4 --- /dev/null +++ b/mirrorApi.code-workspace @@ -0,0 +1,148 @@ +{ + "folders": [ + { "path": "D:/Projetos/MirrorAPI" } + ], + "settings": { + // === GERAL === + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit", + "source.organizeImports": "explicit" + }, + "editor.formatOnPaste": false, + "editor.formatOnType": false, + "editor.minimap.enabled": false, + "files.trimTrailingWhitespace": true, + "files.autoSave": "onFocusChange", + "telemetry.telemetryLevel": "off", + "update.mode": "manual", + + // === PERFORMANCE === + "files.watcherExclude": { + "**/__pycache__/**": true, + "**/.mypy_cache/**": true, + + "**/.pytest_cache/**": true, + "**/.venv/**": true, + "**/venv/**": true, + "**/.git/**": true + }, + "search.exclude": { + "**/__pycache__": true, + "**/.git": true, + "**/.mypy_cache": true, + "**/.pytest_cache": true + }, + + // === PYTHON === + "python.defaultInterpreterPath": "D:/Projetos/MirrorAPI/venv/Scripts/python.exe", + "python.analysis.typeCheckingMode": "off", + "python.analysis.useLibraryCodeForTypes": true, + "python.languageServer": "Pylance", + "python.formatting.provider": "black", + "python.formatting.blackArgs": ["--line-length", "100"], + "python.linting.enabled": true, + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.flake8Args": ["--max-line-length=100"], + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.formatOnSave": true + }, + + // === TERMINAIS INTEGRADOS === + "terminal.integrated.profiles.windows": { + "FastAPI Dev": { + "path": "cmd.exe", + "args": [ + "/k", + "cd D:\\Projetos\\MirrorAPI && venv\\Scripts\\activate && uvicorn main:app --reload --log-level debug" + ] + }, + "FastAPI Prod": { + "path": "cmd.exe", + "args": [ + "/k", + "cd D:\\Projetos\\MirrorAPI && venv\\Scripts\\activate && uvicorn main:app --host 0.0.0.0 --port 8000" + ] + }, + "Python Shell": { + "path": "cmd.exe", + "args": ["/k", "cd D:\\Projetos\\MirrorAPI && venv\\Scripts\\activate"] + }, + "Git Bash": { + "path": "C:\\Program Files\\Git\\bin\\bash.exe" + } + }, + "terminal.integrated.defaultProfile.windows": "Git Bash", + + // === GIT === + "git.enabled": true, + "git.autorefresh": false, + "git.fetchOnPull": true, + "git.confirmSync": false, + + // === VISUAL === + "workbench.colorTheme": "Default Dark Modern", + "window.zoomLevel": 0, + "breadcrumbs.enabled": true, + "explorer.compactFolders": false, + + // === TESTES === + "python.testing.pytestEnabled": true, + "python.testing.unittestEnabled": false, + "python.testing.autoTestDiscoverOnSaveEnabled": true, + + // === MISC === + "files.exclude": { + "**/.DS_Store": true, + "**/*.log": true + } + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "Debug FastAPI", + "type": "python", + "request": "launch", + "module": "uvicorn", + "args": [ + "main:app", + "--reload", + "--host", + "127.0.0.1", + "--port", + "8000" + ], + "jinja": true, + "justMyCode": true, + "cwd": "${workspaceFolder}", + "env": { + "PYTHONPATH": "${workspaceFolder}" + } + }, + { + "name": "Pytest All", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/venv/Scripts/pytest.exe", + "args": ["-v"], + "console": "integratedTerminal" + } + ] + }, + "extensions": { + "recommendations": [ + // === PYTHON === + "ms-python.python", + "ms-python.black-formatter", + "ms-python.flake8", + "ms-python.pylance", + "littlefoxteam.vscode-python-test-adapter", + + // === GIT === + "eamodio.gitlens" + ] + } +} diff --git a/requirements.txt b/requirements.txt index 5cbebd6..2615e14 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,3 +32,4 @@ starlette==0.47.2 typing-inspection==0.4.1 typing_extensions==4.14.1 uvicorn==0.35.0 +psycopg2-binary>=2.9.9 diff --git a/teste.py b/teste.py new file mode 100644 index 0000000..ae0a328 --- /dev/null +++ b/teste.py @@ -0,0 +1,10 @@ +import psycopg2 + +conn = psycopg2.connect( + dbname="mirror", + user="postgres", + password="mirrorapidb", + host="127.0.0.1", # localhost + port=5432, + options="-c client_encoding=LATIN1", # troque LATIN1 por UTF8 se o banco for UTF8 +)