This demo aims to provide a set of examples and frameworks for doing test-driven data engineering (TDDE).
To run this demo, the following applications must be installed.
Tool | Mac Demo Version | Windows Version |
---|---|---|
Python | Python 3.8.2 | |
Docker | docker desktop (really only need docker)
|
|
dbt | dbt 0.20.1_1 | |
dbt-sqlserver plugin | 0.19.0 NOTE: 0.20.0 did not install properly, so downgraded to 0.19.0 |
|
dbt-snowflake plugin | 0.20.1 |
Below are some references that have been used to learn more about the activities in this repo. It is recommended to read them for yourself as you start/continue the dbt
journey.
- DBT Slack Channel Join Here
- Building a Scalable Analytics Architecture with Airflow and dbt
- Part 1
- Part 2
- Data Mock Tool Plugin
- GitLab dbt Guide
- dbt coves
- Flight data dictionary on BTS.gov
Pull the Docker Image Pull the docker image you'd like to use. The MS SQL Server dockerhub page is a good resource.
COMMAND:
docker pull mcr.microsoft.com/mssql/server:2019-latest
Run the Docker Image Run the docker image to start a container that has MS SQL Server running within it.
COMMAND:
docker run -d --name sql_server -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=ITsC0mpl1cat3d' -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest
There are multiple ways to verify the image, two are:
- Connect a SQL Prompt within the container (via docker tools)
- Connect to the SQL instance using a connection (similar to normal connection)
Using docker tools, you can open a command prompt inside the SQL Server docker container. The container has the mssql-tools
pre-installed.
The command below will open a sqlcmd
prompt inside the docker container, using the username and password provided.
docker exec -it sql_server /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ITsC0mpl1cat3d
Verify you have a running instance with a simple select
query (don't forget the go
):
1> select @@version
2> go
The response should look similar to the response below:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU12) (KB5004524) - 15.0.4153.1 (X64)
Jul 19 2021 15:37:34
Copyright (C) 2019 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 20.04.2 LTS) <X64>
(1 rows affected)
Setting up your Mac to use sqlcmd
requires a couple of additional steps:
- Install the SQL Server drivers and sql tools
- Connect to SQL Server using the ODBC connection
First, install the MSSQL ODBC Drivers AND MSSQL tools using the code in this reference (code below).
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools
Next, verify you can connect to the SQL Server Docker instance and run the select @@version
, and your response should be the same as with the docker command verification above:
% sqlcmd -S localhost -U sa -P ITsC0mpl1cat3d
1> select @@version
2> go
NOTE: There are alternate ways to connect using the ODBC driver. This may help if you need other means.
- Connect using localhost + port
sqlcmd -S localhost,1433 -U sa -P ITsC0mpl1cat3d
- Connect using localhost IP + port
sqlcmd -S 127.0.0.1,1433 -U sa -P ITsC0mpl1cat3d
- Connect using configured IP + port
sqlcmd -S 0.0.0.0,1433 -U sa -P ITsC0mpl1cat3d
If you want to take the SQL Server container down, just run the stop command:
docker stop sql_server
Next time you need the container:
docker start sql_server