-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
12 changed files
with
41 additions
and
51 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
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
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
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
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
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
from functools import lru_cache | ||
|
||
from edgy import Database, Registry | ||
|
||
|
||
@lru_cache() | ||
def get_db_connection(): | ||
# use echo=True for getting the connection infos printed | ||
database = Database("postgresql+asyncpg://user:pass@localhost:5432/my_database", echo=True) | ||
return Registry(database=database) | ||
from edgy import Registry | ||
|
||
# use echo=True for getting the connection infos printed, extra kwargs are passed to main database | ||
return Registry("postgresql+asyncpg://user:pass@localhost:5432/my_database", echo=True) |
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
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
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
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 |
---|---|---|
@@ -1,23 +1,9 @@ | ||
import sys | ||
import os | ||
from functools import lru_cache | ||
|
||
|
||
# we need this also here because we access settings and must be sure the import path is importable | ||
def build_path(): | ||
""" | ||
Builds the path of the project and project root. | ||
""" | ||
SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
if SITE_ROOT not in sys.path: | ||
sys.path.append(SITE_ROOT) | ||
# in case of apps | ||
sys.path.append(os.path.join(SITE_ROOT, "apps")) | ||
|
||
|
||
@lru_cache() | ||
def get_db_connection(): | ||
# Encapsulate to delay the import | ||
from esmerald.conf import settings | ||
|
||
return settings.db_connection |
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
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