1
1
2
2
from contextlib import contextmanager
3
- from dataclasses import dataclass
3
+ from dataclasses import dataclass , field
4
4
import glob
5
5
import os .path
6
6
import sqlite3
7
- from typing import Optional , Tuple , Any , Dict
7
+ from typing import Optional , Tuple , Any , Dict , List
8
8
9
9
10
10
from dbt .adapters .base import Credentials
@@ -25,7 +25,7 @@ class SQLiteCredentials(Credentials):
25
25
26
26
schemas_and_paths : Dict [str , str ]
27
27
schema_directory : str
28
- extensions : Optional [str ] = None
28
+ extensions : List [str ] = field ( default_factory = list )
29
29
30
30
@property
31
31
def type (self ):
@@ -40,16 +40,16 @@ class SQLiteConnectionManager(SQLConnectionManager):
40
40
TYPE = "sqlite"
41
41
42
42
@classmethod
43
- def open (cls , connection ):
43
+ def open (cls , connection : Connection ):
44
44
if connection .state == "open" :
45
45
logger .debug ("Connection is already open, skipping open." )
46
46
return connection
47
47
48
- credentials = connection .credentials
48
+ credentials : SQLiteCredentials = connection .credentials
49
49
50
50
schemas_and_paths = {}
51
51
for schema , path in credentials .schemas_and_paths .items ():
52
- # store abs path so we can tell if we've attached the file already
52
+ # Make .db file path absolute
53
53
schemas_and_paths [schema ] = os .path .abspath (path )
54
54
55
55
try :
@@ -58,12 +58,10 @@ def open(cls, connection):
58
58
else :
59
59
raise FailedToConnectException ("at least one schema must be called 'main'" )
60
60
61
- extensions = [e for e in (connection .credentials .extensions or "" ).split (";" ) if e ]
62
-
63
- if len (extensions ) > 0 :
61
+ if len (credentials .extensions ) > 0 :
64
62
handle .enable_load_extension (True )
65
63
66
- for ext_path in extensions :
64
+ for ext_path in credentials . extensions :
67
65
handle .load_extension (ext_path )
68
66
69
67
cursor = handle .cursor ()
0 commit comments