28
28
29
29
import sqlalchemy
30
30
from alembic .runtime .migration import MigrationContext
31
- from lsst .daf .butler import ButlerConfig
32
- from lsst .daf .butler .core .repoRelocation import replaceRoot
31
+ from lsst .daf .butler import ButlerConfig , RegistryConfig
33
32
34
33
from . import revision
35
34
@@ -59,7 +58,7 @@ class Database:
59
58
dimensions_config_manager = "dimensions-config"
60
59
"""Name of the special dimensions-config pseudo-manager (`str`)"""
61
60
62
- def __init__ (self , db_url : str , schema : Optional [str ] = None ):
61
+ def __init__ (self , db_url : sqlalchemy . engine . url . URL , schema : Optional [str ] = None ):
63
62
self ._db_url = db_url
64
63
self ._schema = schema
65
64
@@ -74,11 +73,10 @@ def from_repo(cls, repo: str) -> Database:
74
73
"butler.yaml" file.
75
74
"""
76
75
butlerConfig = ButlerConfig (repo )
77
- if "root" in butlerConfig :
78
- butlerRoot = butlerConfig ["root" ]
79
- else :
80
- butlerRoot = butlerConfig .configDir
81
- db_url = replaceRoot (butlerConfig ["registry" , "db" ], butlerRoot )
76
+ registryConfig = RegistryConfig (butlerConfig )
77
+ butlerRoot = butlerConfig .get ("root" , butlerConfig .configDir )
78
+ registryConfig .replaceRoot (butlerRoot )
79
+ db_url = registryConfig .connectionString
82
80
schema : Optional [str ] = None
83
81
try :
84
82
schema = butlerConfig ["registry" , "namespace" ]
@@ -91,7 +89,7 @@ def from_repo(cls, repo: str) -> Database:
91
89
@property
92
90
def db_url (self ) -> str :
93
91
"""URL for registry database (`str`)"""
94
- return self ._db_url
92
+ return str ( self ._db_url )
95
93
96
94
@property
97
95
def schema (self ) -> Optional [str ]:
0 commit comments