-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .redis import redis_client | ||
from .postgresql_conn import async_session, engine | ||
|
||
__all__ = ["redis_client", "async_session", "engine"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
Create a connection to the PostgreSQL database using SQLAlchemy's asyncpg driver. | ||
""" | ||
|
||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker | ||
from scraper.src.config import settings | ||
|
||
engine = create_async_engine( | ||
f"postgresql+asyncpg://{settings.PG_USER}:{settings.PG_PW}@{settings.PG_HOST}/{settings.PG_DB}" | ||
) | ||
async_session = async_sessionmaker(engine, expire_on_commit=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
Create a Redis client to interact with the Redis server. | ||
""" | ||
|
||
import redis | ||
from scraper.src.config import settings | ||
|
||
redis_client = redis.Redis( | ||
host=settings.REDIS_HOST, | ||
port=settings.REDIS_PORT, | ||
password=settings.REDIS_PW, | ||
db=settings.REDIS_DB, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters