-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DH5669/store db dialect in database connection collection (#447)
* DH5669/store db dialect in database connection collection * modify the code for the tests * test the response * DH5669/removing the validation on object for dialect * DH5669/adding the script to update dialect * DH5669/reformat with black * DH5669/rename the function to make more sense
- Loading branch information
1 parent
5f2c7a4
commit 809ac31
Showing
5 changed files
with
57 additions
and
5 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,25 @@ | ||
import dataherald.config | ||
from dataherald.config import System | ||
from dataherald.db import DB | ||
from dataherald.sql_database.models.types import DatabaseConnection | ||
from dataherald.utils.encrypt import FernetEncrypt | ||
|
||
if __name__ == "__main__": | ||
settings = dataherald.config.Settings() | ||
system = System(settings) | ||
system.start() | ||
storage = system.instance(DB) | ||
fernet_encrypt = FernetEncrypt() | ||
database_connections = storage.find_all("database_connections") | ||
for database_connection in database_connections: | ||
if not database_connection.get("dialect"): | ||
decrypted_uri = fernet_encrypt.decrypt( | ||
database_connection["connection_uri"] | ||
) | ||
dialect_prefix = DatabaseConnection.get_dialect(decrypted_uri) | ||
dialect = DatabaseConnection.set_dialect(dialect_prefix) | ||
storage.update_or_create( | ||
"database_connections", | ||
{"_id": database_connection["_id"]}, | ||
{"dialect": dialect}, | ||
) |
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