mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
chore: prepare cloud merge point with docker and firebase configs in movexe fork Boris account? No, current user.
This commit is contained in:
parent
b38a297349
commit
4a6b335ce3
14 changed files with 263 additions and 2 deletions
21
surfsense_backend/.gcloudignore
Normal file
21
surfsense_backend/.gcloudignore
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
.gcloudignore
|
||||
.git
|
||||
.gitignore
|
||||
.venv
|
||||
venv
|
||||
ENV
|
||||
env
|
||||
__pycache__
|
||||
.pytest_cache
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
.env
|
||||
.env.yaml
|
||||
uv.lock
|
||||
pyproject.toml
|
||||
node_modules
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.db
|
||||
data/
|
||||
|
|
@ -30,7 +30,7 @@ def load_uvicorn_config(args=None):
|
|||
config_kwargs = {
|
||||
"app": "app.app:app",
|
||||
"host": os.getenv("UVICORN_HOST", "0.0.0.0"),
|
||||
"port": int(os.getenv("UVICORN_PORT", 8000)),
|
||||
"port": int(os.getenv("UVICORN_PORT", os.getenv("PORT", 8000))),
|
||||
"log_level": os.getenv("UVICORN_LOG_LEVEL", "info"),
|
||||
"reload": args.reload if args else False,
|
||||
"reload_dirs": ["app"] if (args and args.reload) else None,
|
||||
|
|
|
|||
21
surfsense_backend/test_db.py
Normal file
21
surfsense_backend/test_db.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import asyncio
|
||||
import asyncpg
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
async def main():
|
||||
load_dotenv()
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
if db_url.startswith("postgresql+asyncpg"):
|
||||
db_url = db_url.replace("postgresql+asyncpg", "postgresql")
|
||||
|
||||
print(f"Connecting to {db_url}")
|
||||
try:
|
||||
conn = await asyncpg.connect(db_url)
|
||||
print("SUCCESS: Connected to Neon DB!")
|
||||
await conn.close()
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
25
surfsense_backend/test_db_sa.py
Normal file
25
surfsense_backend/test_db_sa.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import asyncio
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy import text
|
||||
|
||||
async def main():
|
||||
load_dotenv()
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
db_url = db_url.replace("postgresql+asyncpg", "postgresql+psycopg")
|
||||
if "ssl=require" in db_url:
|
||||
db_url = db_url.replace("ssl=require", "sslmode=require")
|
||||
engine = create_async_engine(db_url)
|
||||
print(f"Connecting to {db_url} using SQLAlchemy async psycopg")
|
||||
try:
|
||||
async with engine.begin() as conn:
|
||||
res = await conn.execute(text("SELECT 1"))
|
||||
print(f"SUCCESS! Result: {res.scalar()}")
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
19
surfsense_backend/test_db_sync.py
Normal file
19
surfsense_backend/test_db_sync.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import psycopg
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
def main():
|
||||
load_dotenv()
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
db_url = db_url.replace("postgresql+asyncpg://", "postgresql://")
|
||||
db_url = db_url.replace("ssl=require", "sslmode=require")
|
||||
|
||||
print(f"Connecting to {db_url} using PSYCOPG")
|
||||
try:
|
||||
with psycopg.connect(db_url) as conn:
|
||||
print("SUCCESS: Connected to Neon DB via Psycopg!")
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue