Skip to content

Commit

Permalink
Update init_pg.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxin688 authored Jan 19, 2024
1 parent 937e7f6 commit 8f51518
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions deploy/init_pg.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import asyncio

from sqlalchemy import text
from sqlalchemy.ext.asyncio import AsyncSession

from src.db.session import async_session

async def create_pg_extensions() -> None:
async with async_session() as session:
await session.execute(text('create EXTENSION if not EXISTS "pgcrypto"'))
await session.execute(text('create EXTENSION if not EXISTS "hstore"'))
await session.commit()

if __name__ == "__main__":
asyncio.run(create_pg_extensions())


async def create_pg_extensions(session: AsyncSession) -> None:
await session.execute(text('create EXTENSION if not EXISTS "pgcrypto"'))
await session.execute(text('create EXTENSION if not EXISTS "hstore"'))
await session.commit()

0 comments on commit 8f51518

Please sign in to comment.