Skip to content

Commit 1db91dc

Browse files
Use YAML object
Replace colon-separated schema mapping with a YAML object.
1 parent 126647f commit 1db91dc

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ dbt_sqlite:
6767
schema: 'main'
6868

6969
# connect schemas to paths: at least one of these must be 'main'
70-
schemas_and_paths: 'main=/my_project/data/etl.db;dataset=/my_project/data/dataset_v1.db'
70+
schemas_and_paths:
71+
main: '/my_project/data/etl.db'
72+
dataset: '/my_project/data/dataset_v1.db'
7173

7274
# directory where all *.db files are attached as schema, using base filename
7375
# as schema name, and where new schema are created. this can overlap with the dirs of

dbt/adapters/sqlite/connections.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import glob
55
import os.path
66
import sqlite3
7-
from typing import Optional, Tuple, Any
7+
from typing import Optional, Tuple, Any, Dict
88

99

1010
from dbt.adapters.base import Credentials
@@ -23,7 +23,7 @@
2323
class SQLiteCredentials(Credentials):
2424
""" Required connections for a SQLite connection"""
2525

26-
schemas_and_paths: str
26+
schemas_and_paths: Dict[str, str]
2727
schema_directory: str
2828
extensions: Optional[str] = None
2929

@@ -48,8 +48,7 @@ def open(cls, connection):
4848
credentials = connection.credentials
4949

5050
schemas_and_paths = {}
51-
for path_entry in credentials.schemas_and_paths.split(";"):
52-
schema, path = path_entry.split("=", 1)
51+
for schema, path in credentials.schemas_and_paths.items():
5352
# store abs path so we can tell if we've attached the file already
5453
schemas_and_paths[schema] = os.path.abspath(path)
5554

test/sqlite.dbtspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ target:
33
type: sqlite
44
database: adapter_test
55
schema: 'main'
6-
schemas_and_paths: "main=/tmp/dbt-sqlite-tests/adapter_test.db"
6+
schemas_and_paths:
7+
main: '/tmp/dbt-sqlite-tests/adapter_test.db'
78
schema_directory: '/tmp/dbt-sqlite-tests'
89
extensions: "/home/jeff/git/sqlite-digest/digest.so"
910
threads: 1

0 commit comments

Comments
 (0)