Skip to content

Commit 692e38e

Browse files
committed
add lots of notes to README
1 parent e66d30c commit 692e38e

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,29 @@ Install this package.
1212

1313
Create an entry in your `~/.dbt/profiles.yml` file with the following configuration:
1414

15-
```
15+
```YAML
1616
dbt_sqlite:
1717

1818
target: dev
1919
outputs:
2020
dev:
2121
type: sqlite
22+
23+
# sqlite locks the whole db on writes so anything > 1 won't help
2224
threads: 1
25+
2326
# value of 'database' is arbitrary
2427
database: "database"
28+
2529
# value of 'schema' must be defined in schema_paths below. in most cases, this should be 'main'
2630
schema: 'main'
31+
2732
# connect schemas to paths: at least one of these must be 'main'
2833
schemas_and_paths: 'main=/my_project/data/etl.db;dataset=/my_project/data/dataset_v1.db'
34+
2935
# directory where new schemas are created by dbt as new database files
3036
schema_directory: '/myproject/data/schemas'
37+
3138
# optional: semi-colon separated list of file paths for SQLite extensions to load.
3239
# digesto.so is needed to provide the md5 function needed for snapshots to work.
3340
# see section in README on how to install it
@@ -43,15 +50,26 @@ Set `profile: 'dbt_sqlite'` in your project's `dbt_project.yml` file.
4350
stripped from the output of `ref()` and from SQL everywhere. It still
4451
needs to be set in the configuration and is used by dbt internally.
4552

46-
- Schema are implemented as attached database files. SQLite automatically
47-
assigns 'main' to the database file you initially connect to. (TODO: add warning
48-
about references and renaming schemas/database files, and what creating/schemas
49-
does)
53+
- Schema are implemented as attached database files. (SQLite conflates databases
54+
and schemas.)
55+
56+
- SQLite automatically assigns 'main' to the file you initially connect to,
57+
so this must be defined in your profile. Other schemas defined in your profile
58+
get attached when database connection is created.
59+
60+
- If dbt needs to create a new schema, it will be created in `schema_directory`.
61+
Dropping a schema results in dropping all its relations but NOT detaching the
62+
database, since this may result in a confusing conflict with the schemas you
63+
defined in your profile.
5064

51-
- SQLite does not allow views in one schema (i.e. database file) to reference
52-
objects in another schema. You'll get this error from SQLite: "view [someview]
53-
cannot reference objects in database [somedatabase]". You must set
54-
`materialized='table'` in models that reference other schemas.
65+
- Schema names are stored in view definitions, so when you access a non-'main'
66+
database file outside dbt, you'll need to attach it using the same name, or
67+
the views won't work.
68+
69+
- SQLite does not allow views in one schema (i.e. database file) to reference
70+
objects in another schema. You'll get this error from SQLite: "view [someview]
71+
cannot reference objects in database [somedatabase]". You must set
72+
`materialized='table'` in models that reference other schemas.
5573

5674
- Materializations are simplified: they drop and re-create the model, instead of
5775
doing the backup-and-swap-in new mode that the other dbt database adapters
@@ -84,10 +102,7 @@ example above.
84102

85103
## Development Notes / TODOs
86104

87-
- snapshots don't quite work yet, but getting there
88-
89-
- incremental materializations seem to work but incremental test in the adapter
90-
suite fails for some reason
105+
...
91106

92107
## Running Tests
93108

@@ -110,3 +125,8 @@ between runs of pytest, otherwise leftover state from failures can mess up subse
110125

111126
Inspired by this initial work by stephen1000: https://github.com/stephen1000/dbt_sqlite
112127

128+
https://github.com/jwills/dbt-duckdb/ - useful for ideas on working with
129+
another embedded database
130+
131+
https://github.com/fishtown-analytics/dbt-spark/ - spark also has two-part
132+
relation names (no 'database')

0 commit comments

Comments
 (0)