chore(db): default to local postgres host

This commit is contained in:
dev-worker 2026-03-31 08:56:11 +00:00
parent b3bc2d8250
commit 47494a9c86
10 changed files with 12 additions and 12 deletions

View File

@ -35,7 +35,7 @@ logging.basicConfig(
)
logger = logging.getLogger("backtest")
PG_HOST = os.getenv("PG_HOST", "10.106.0.3")
PG_HOST = os.getenv("PG_HOST", "127.0.0.1")
PG_PORT = int(os.getenv("PG_PORT", "5432"))
PG_DB = os.getenv("PG_DB", "arb_engine")
PG_USER = os.getenv("PG_USER", "arb")

View File

@ -1,6 +1,6 @@
"""
db.py PostgreSQL 数据库连接层
统一连接到 Cloud SQLPG_HOST 默认 10.106.0.3
统一连接到 Cloud SQLPG_HOST 默认 127.0.0.1
同步连接池psycopg2供脚本类使用
异步连接池asyncpg供FastAPI使用
"""
@ -13,7 +13,7 @@ import psycopg2.pool
from contextlib import contextmanager
# PG连接参数统一连接 Cloud SQL
PG_HOST = os.getenv("PG_HOST", "10.106.0.3")
PG_HOST = os.getenv("PG_HOST", "127.0.0.1")
PG_PORT = int(os.getenv("PG_PORT", 5432))
PG_DB = os.getenv("PG_DB", "arb_engine")
PG_USER = os.getenv("PG_USER", "arb")

View File

@ -5,8 +5,8 @@ module.exports = {
interpreter: "python3",
cwd: "/root/Projects/arbitrage-engine/backend",
env: {
PG_HOST: "34.85.117.248",
CLOUD_PG_HOST: "34.85.117.248",
PG_HOST: "127.0.0.1",
CLOUD_PG_HOST: "127.0.0.1",
CLOUD_PG_ENABLED: "true"
}
}]

View File

@ -49,7 +49,7 @@ if not _DB_PASSWORD:
sys.exit(1)
DB_CONFIG = {
"host": os.getenv("DB_HOST", "10.106.0.3"),
"host": os.getenv("DB_HOST", "127.0.0.1"),
"port": int(os.getenv("DB_PORT", "5432")),
"dbname": os.getenv("DB_NAME", "arb_engine"),
"user": os.getenv("DB_USER", "arb"),

View File

@ -12,7 +12,7 @@ from psycopg2.extras import Json
SYMBOLS = ["BTCUSDT", "ETHUSDT", "XRPUSDT", "SOLUSDT"]
INTERVAL_SECONDS = 300
PG_HOST = os.getenv("PG_HOST", "10.106.0.3")
PG_HOST = os.getenv("PG_HOST", "127.0.0.1")
PG_PORT = int(os.getenv("PG_PORT", "5432"))
PG_DB = os.getenv("PG_DB", "arb_engine")
PG_USER = os.getenv("PG_USER", "arb")

View File

@ -12,7 +12,7 @@ import sys
import psycopg2
from psycopg2.extras import execute_values
PG_HOST = os.environ.get("PG_HOST", "10.106.0.3")
PG_HOST = os.environ.get("PG_HOST", "127.0.0.1")
PG_PASS = os.environ.get("PG_PASS", "arb_engine_2026")
PG_USER = "arb"
PG_DB = "arb_engine"

View File

@ -22,7 +22,7 @@ import os, sys
import psycopg2
from psycopg2.extras import RealDictCursor
PG_HOST = os.getenv("PG_HOST", "10.106.0.3")
PG_HOST = os.getenv("PG_HOST", "127.0.0.1")
PG_USER = os.getenv("PG_USER", "arb")
PG_PASS = os.getenv("PG_PASS", "arb_engine_2026")
PG_DB = os.getenv("PG_DB", "arb_engine")

View File

@ -40,7 +40,7 @@ if not _DB_PASSWORD:
sys.exit(1)
DB_CONFIG = {
"host": os.getenv("DB_HOST", "10.106.0.3"),
"host": os.getenv("DB_HOST", "127.0.0.1"),
"port": int(os.getenv("DB_PORT", "5432")),
"dbname": os.getenv("DB_NAME", "arb_engine"),
"user": os.getenv("DB_USER", "arb"),

View File

@ -47,7 +47,7 @@ if not _DB_PASSWORD:
sys.exit(1)
DB_CONFIG = {
"host": os.getenv("DB_HOST", "10.106.0.3"),
"host": os.getenv("DB_HOST", "127.0.0.1"),
"port": int(os.getenv("DB_PORT", "5432")),
"dbname": os.getenv("DB_NAME", "arb_engine"),
"user": os.getenv("DB_USER", "arb"),

View File

@ -239,7 +239,7 @@ def replay_trade(cur, tid, symbol, direction, strategy, entry_ts, atr):
def main(dry_run=False):
conn = psycopg2.connect(host='10.106.0.3', dbname='arb_engine', user='arb', password='arb_engine_2026')
conn = psycopg2.connect(host='127.0.0.1', dbname='arb_engine', user='arb', password='arb_engine_2026')
cur = conn.cursor()
cur.execute("""