Skip to content

Commit 8109629

Browse files
Use array for extensions
1 parent 1db91dc commit 8109629

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ dbt_sqlite:
7878

7979
# optional: semi-colon separated list of file paths for SQLite extensions to load.
8080
# crypto.so is needed to provide for snapshots to work; see README
81-
extensions: "/path/to/sqlean/crypto.so"
81+
extensions:
82+
- "/path/to/sqlean/crypto.so"
8283

8384
```
8485

dbt/adapters/sqlite/connections.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
from contextlib import contextmanager
3-
from dataclasses import dataclass
3+
from dataclasses import dataclass, field
44
import glob
55
import os.path
66
import sqlite3
7-
from typing import Optional, Tuple, Any, Dict
7+
from typing import Optional, Tuple, Any, Dict, List
88

99

1010
from dbt.adapters.base import Credentials
@@ -25,7 +25,7 @@ class SQLiteCredentials(Credentials):
2525

2626
schemas_and_paths: Dict[str, str]
2727
schema_directory: str
28-
extensions: Optional[str] = None
28+
extensions: List[str] = field(default_factory=list)
2929

3030
@property
3131
def type(self):
@@ -40,16 +40,16 @@ class SQLiteConnectionManager(SQLConnectionManager):
4040
TYPE = "sqlite"
4141

4242
@classmethod
43-
def open(cls, connection):
43+
def open(cls, connection: Connection):
4444
if connection.state == "open":
4545
logger.debug("Connection is already open, skipping open.")
4646
return connection
4747

48-
credentials = connection.credentials
48+
credentials: SQLiteCredentials = connection.credentials
4949

5050
schemas_and_paths = {}
5151
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
5353
schemas_and_paths[schema] = os.path.abspath(path)
5454

5555
try:
@@ -58,12 +58,10 @@ def open(cls, connection):
5858
else:
5959
raise FailedToConnectException("at least one schema must be called 'main'")
6060

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:
6462
handle.enable_load_extension(True)
6563

66-
for ext_path in extensions:
64+
for ext_path in credentials.extensions:
6765
handle.load_extension(ext_path)
6866

6967
cursor = handle.cursor()

test/sqlite.dbtspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ target:
66
schemas_and_paths:
77
main: '/tmp/dbt-sqlite-tests/adapter_test.db'
88
schema_directory: '/tmp/dbt-sqlite-tests'
9-
extensions: "/home/jeff/git/sqlite-digest/digest.so"
9+
extensions:
10+
- "/home/spoton/edgar/sqlite-digest/digest.so"
1011
threads: 1
1112
sequences:
1213
test_dbt_empty: empty

0 commit comments

Comments
 (0)