-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #250 from bluelabsio/RM-96-rewrite-DBDriver-so-cur…
…rent-db-becomes-a-connection-db_engine-takes-all-Engine-responsibilities RM-96-rewrite-DBDriver-so-current-db-becomes-a-connection-db_engine-takes-all-Engine-responsibilities
- Loading branch information
Showing
105 changed files
with
1,113 additions
and
654 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1 | ||
0 |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# flake8: noqa | ||
|
||
import sqlalchemy | ||
from typing import Union, Optional, Tuple | ||
import warnings | ||
|
||
|
||
def check_db_conn_engine(db: Optional[Union[sqlalchemy.engine.Engine, | ||
sqlalchemy.engine.Connection]] = None, | ||
db_conn: Optional[sqlalchemy.engine.Connection] = None, | ||
db_engine: Optional[sqlalchemy.engine.Engine] = None) -> \ | ||
Tuple[Optional[Union[sqlalchemy.engine.Engine, | ||
sqlalchemy.engine.Connection]], | ||
Optional[sqlalchemy.engine.Connection], | ||
sqlalchemy.engine.Engine]: | ||
if db: | ||
warnings.warn("The db argument is deprecated and will be" | ||
"removed in future releases.\n" | ||
"Please use db_conn for Connection objects and db_engine for Engine" | ||
"objects.", | ||
DeprecationWarning) | ||
if not (db or db_conn or db_engine): | ||
raise ValueError("Either db, db_conn, or db_engine must be provided as arguments") | ||
if isinstance(db, sqlalchemy.engine.Connection) and not db_conn: | ||
db_conn = db | ||
if isinstance(db, sqlalchemy.engine.Engine) and not db_engine: | ||
db_engine = db | ||
if not db_engine: | ||
print("db_engine is not provided, so we're creating one from db_conn") | ||
db_engine = db_conn.engine # type: ignore[union-attr] | ||
return (db, db_conn, db_engine) # type: ignore[return-value] |
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
Oops, something went wrong.