-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DH5669/adding the script to update dialect
- Loading branch information
1 parent
941493a
commit e2a6fc3
Showing
1 changed file
with
23 additions
and
0 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,23 @@ | ||
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.validate_uri(decrypted_uri) | ||
dialect = DatabaseConnection.set_dialect(dialect_prefix) | ||
storage.update_or_create( | ||
"database_connections", | ||
{"_id": database_connection["_id"]}, | ||
{"dialect": dialect}, | ||
) |