Skip to content

Commit 62add2b

Browse files
committed
logger.info2
1 parent 1a1860b commit 62add2b

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

fastapi-postgres/common/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# flyctl proxy 5432 -a full-stack-db
1919
if IS_LOCAL:
2020
DATABASE_URL = DATABASE_URL
21+
# DATABASE_URL = "postgresql+asyncpg://postgres:e0CEeFYUY7kERQcW@aws-0-us-east-1.pooler.supabase.com:6543/postgres"
2122
# DATABASE_URL = DATABASE_URL_PROD
2223

2324
class Settings:

fastapi-postgres/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
from app import create_app
1+
import os
2+
3+
4+
5+
6+
DATABASE_URL_PROD = os.environ.get("DATABASE_URL")
27
from common.config import conf
38
from common.utils.log import logger
49

510
logger.info(conf.POSTGRES_DATABASE_URL)
6-
11+
logger.info(os.environ.get("DATABASE_URL"))
12+
logger.info(f'{os.getenv("USER") },{os.environ.get("USER_LOCAL")}')
13+
from app import create_app
714
app = create_app(docs=True)

fastapi-postgres/service/create_data.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
async def create_fake_data():
1313
fake = Faker()
1414

15-
engine = create_async_engine(conf.POSTGRES_DATABASE_URL, echo=False)
15+
engine = create_async_engine(conf.POSTGRES_DATABASE_URL, connect_args={
16+
"ssl": "require",
17+
# optional: if still using pooler
18+
"statement_cache_size": 0
19+
},
20+
echo=True
21+
)
1622
DBModel.engine = engine
1723

1824
async with engine.begin() as conn:

0 commit comments

Comments
 (0)