Loading Data from Aladtec
to Microsoft SQL Server
in Python with dlt
Join our Slack community or book a call with our support engineer Violetta.
Aladtec
is a robust scheduling and workforce management system designed for public safety and healthcare organizations. It helps streamline employee scheduling, manage shift trades, and track work hours efficiently. With Aladtec
, organizations can optimize staffing, reduce scheduling conflicts, and ensure compliance with labor laws. The platform offers features like automated scheduling, time-off requests, and detailed reporting to enhance productivity and operational efficiency. This documentation covers how to load data from Aladtec
into Microsoft SQL Server
, a relational database management system (RDBMS). Applications and tools connect to a SQL Server
instance or database and communicate using Transact-SQL. We will use the open-source Python library called dlt
to facilitate this data transfer. Further information about Aladtec
is available at Aladtec's official website.
dlt
Key Features
- Easy to get started:
dlt
is a Python library that is easy to use and understand. It is designed to be simple to use and easy to understand. Typepip install dlt
and you are ready to go. Getting Started - Governance Support:
dlt
pipelines offer robust governance support through metadata utilization, schema enforcement, and schema change alerts. Governance Support - Data Lineage: Track data loads and facilitate data lineage and traceability with
dlt
's load IDs. Data Lineage - Schema Management: Enforce and curate schemas to ensure data consistency and quality. Schema Management
- Scaling and Performance:
dlt
offers several mechanisms and configuration options to scale up and finetune pipelines. Performance
Getting started with your pipeline locally
dlt-init-openapi
0. Prerequisites
dlt
and dlt-init-openapi
requires Python 3.9 or higher. Additionally, you need to have the pip
package manager installed, and we recommend using a virtual environment to manage your dependencies. You can learn more about preparing your computer for dlt in our installation reference.
1. Install dlt and dlt-init-openapi
First you need to install the dlt-init-openapi
cli tool.
pip install dlt-init-openapi
The dlt-init-openapi
cli is a powerful generator which you can use to turn any OpenAPI spec into a dlt
source to ingest data from that api. The quality of the generator source is dependent on how well the API is designed and how accurate the OpenAPI spec you are using is. You may need to make tweaks to the generated code, you can learn more about this here.
# generate pipeline
# NOTE: add_limit adds a global limit, you can remove this later
# NOTE: you will need to select which endpoints to render, you
# can just hit Enter and all will be rendered.
dlt-init-openapi aladtec --url https://raw.githubusercontent.com/dlt-hub/openapi-specs/main/open_api_specs/Business/aladtec.yaml --global-limit 2
cd aladtec_pipeline
# install generated requirements
pip install -r requirements.txt
The last command will install the required dependencies for your pipeline. The dependencies are listed in the requirements.txt
:
dlt>=0.4.12
You now have the following folder structure in your project:
aladtec_pipeline/
├── .dlt/
│ ├── config.toml # configs for your pipeline
│ └── secrets.toml # secrets for your pipeline
├── rest_api/ # The rest api verified source
│ └── ...
├── aladtec/
│ └── __init__.py # TODO: possibly tweak this file
├── aladtec_pipeline.py # your main pipeline script
├── requirements.txt # dependencies for your pipeline
└── .gitignore # ignore files for git (not required)
1.1. Tweak aladtec/__init__.py
This file contains the generated configuration of your rest_api. You can continue with the next steps and leave it as is, but you might want to come back here and make adjustments if you need your rest_api
source set up in a different way. The generated file for the aladtec source will look like this:
Click to view full file (380 lines)
from typing import List
import dlt
from dlt.extract.source import DltResource
from rest_api import rest_api_source
from rest_api.typing import RESTAPIConfig
@dlt.source(name="aladtec_source", max_table_nesting=2)
def aladtec_source(
token: str = dlt.secrets.value,
base_url: str = dlt.config.value,
) -> List[DltResource]:
# source configuration
source_config: RESTAPIConfig = {
"client": {
"base_url": base_url,
"auth": {
"type": "bearer",
"token": token,
},
"paginator": {
"type":
"offset",
"limit":
100,
"offset_param":
"offset",
"limit_param":
"limit",
"total_path":
"",
"maximum_offset":
20,
},
},
"resources":
[
# Returns a list of all accrual banks.
{
"name": "accrual_bank",
"table_name": "accrual_bank",
"endpoint": {
"data_selector": "data",
"path": "/accrual-banks",
}
},
# Returns Member Availability for the requested date/time range.
{
"name": "availability",
"table_name": "availability",
"endpoint": {
"data_selector": "data",
"path": "/availability",
"params": {
"range_start_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
},
}
},
# Returns the number of hours in each specified accrual bank for a list of provided members.
{
"name": "balance",
"table_name": "balance",
"endpoint": {
"data_selector": "data",
"path": "/accrual-banks/balances",
"params": {
"member_ids": "FILL_ME_IN", # TODO: fill in required query parameter
"accrual_bank_ids": "FILL_ME_IN", # TODO: fill in required query parameter
},
}
},
# Members clocked in at the time of the request.
{
"name": "clocked_in_member",
"table_name": "clocked_in_member",
"endpoint": {
"data_selector": "data",
"path": "/time-clock-time/clocked-in-members",
}
},
# Returns a list of configuration settings.
{
"name": "configuration",
"table_name": "configuration",
"endpoint": {
"data_selector": "$",
"path": "/configuration",
}
},
# Returns all customer created Member Database attribute definitions.
{
"name": "custom_attribute",
"table_name": "custom_attribute",
"endpoint": {
"data_selector": "data",
"path": "/members/custom-attributes",
}
},
# Returns all employee types. These can be customized per Aladtec system. Examples: part time, full time, volunteer.
{
"name": "employee_type",
"table_name": "employee_type",
"endpoint": {
"data_selector": "data",
"path": "/members/employee-types",
}
},
# Events for requested date/time range.
{
"name": "event",
"table_name": "event",
"endpoint": {
"data_selector": "data",
"path": "/events",
"params": {
"range_start_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
# the parameters below can optionally be configured
# "daily_split_time": "OPTIONAL_CONFIG",
},
}
},
# Returns extra hours ranges for a specified period of time in the past.
{
"name": "extra_hour",
"table_name": "extra_hour",
"endpoint": {
"data_selector": "data",
"path": "/extra-hours",
"params": {
"range_start_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
# the parameters below can optionally be configured
# "schedule_ids": "OPTIONAL_CONFIG",
# "member_ids": "OPTIONAL_CONFIG",
# "position_qualification_ids": "OPTIONAL_CONFIG",
# "time_type_ids": "OPTIONAL_CONFIG",
# "statuses": "approved",
# "daily_split_time": "OPTIONAL_CONFIG",
},
}
},
# Returns a list of unique, active Kiosks used to clock in and out.
{
"name": "kiosk",
"table_name": "kiosk",
"primary_key": "kiosk_id",
"write_disposition": "merge",
"endpoint": {
"data_selector": "data",
"path": "/time-clock/kiosks",
}
},
# Returns members and the members' associated Member Database attributes. Attributes must be accessible through the API or the value will be null. Contact Aladtec Support (support@aladtec.com, 888.749.5550) to make attributes accessible through the API.
{
"name": "member",
"table_name": "member",
"primary_key": "member_id",
"write_disposition": "merge",
"endpoint": {
"data_selector": "data",
"path": "/members",
"params": {
# the parameters below can optionally be configured
# "member_ids": "OPTIONAL_CONFIG",
# "include_inactive": "false",
# "attribute_ids": "OPTIONAL_CONFIG",
},
}
},
# Schedule and position for each member scheduled at the time of the request.
{
"name": "members_scheduled_now",
"table_name": "members_scheduled_now",
"endpoint": {
"data_selector": "data",
"path": "/scheduled-time/members-scheduled-now",
"params": {
# the parameters below can optionally be configured
# "schedule_ids": "OPTIONAL_CONFIG",
},
}
},
# Returns Schedule Notes grouped by calendar date. Up to one year can be retrieved in a single request.
{
"name": "note",
"table_name": "note",
"endpoint": {
"data_selector": "data",
"path": "/scheduled-time/notes",
"params": {
"range_start_date": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_date": "FILL_ME_IN", # TODO: fill in required query parameter
# the parameters below can optionally be configured
# "schedule_ids": "OPTIONAL_CONFIG",
},
}
},
# Returns time ranges where no member is scheduled. Typically used for finding shifts needing coverage. Up to one month can be retrieved in a single request.
{
"name": "open_time",
"table_name": "open_time",
"endpoint": {
"data_selector": "data",
"path": "/scheduled-time/open-time",
"params": {
"range_start_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
# the parameters below can optionally be configured
# "schedule_ids": "OPTIONAL_CONFIG",
# "position_ids": "OPTIONAL_CONFIG",
# "include_only_shift_time": "true",
# "daily_split_time": "OPTIONAL_CONFIG",
},
}
},
# Returns a list of unique, active Paycodes which can be applied to time clock time.
{
"name": "paycode",
"table_name": "paycode",
"primary_key": "paycode_id",
"write_disposition": "merge",
"endpoint": {
"data_selector": "data",
"path": "/time-clock/paycodes",
}
},
# Runs the Payroll Report export. <strong>Pagination is required</strong> to export all records within the requested range.
{
"name": "payroll",
"table_name": "payroll",
"endpoint": {
"data_selector": "data",
"path": "/reports/payroll",
"params": {
"range_start_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
# the parameters below can optionally be configured
# "member_ids": "OPTIONAL_CONFIG",
# "time_categories": "OPTIONAL_CONFIG",
# "next_token": "OPTIONAL_CONFIG",
},
}
},
# Returns a list of unique position qualifications.
{
"name": "position_qualification",
"table_name": "position_qualification",
"endpoint": {
"data_selector": "data",
"path": "/schedules/position-qualifications",
}
},
# Schedule configuration defined in an Aladtec system. Data is sorted by the order defined on the Setup -> Schedules page.
{
"name": "schedule",
"table_name": "schedule",
"primary_key": "schedule_id",
"write_disposition": "merge",
"endpoint": {
"data_selector": "data",
"path": "/schedules",
"params": {
# the parameters below can optionally be configured
# "include_archived": "false",
},
}
},
# Returns scheduled time ranges for a specified period of time
{
"name": "scheduled_time",
"table_name": "scheduled_time",
"endpoint": {
"data_selector": "data",
"path": "/scheduled-time",
"params": {
"range_start_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
# the parameters below can optionally be configured
# "schedule_ids": "OPTIONAL_CONFIG",
# "member_ids": "OPTIONAL_CONFIG",
# "position_ids": "OPTIONAL_CONFIG",
# "time_type_ids": "OPTIONAL_CONFIG",
# "daily_split_time": "OPTIONAL_CONFIG",
},
}
},
# Shift Labels for requested date range.
{
"name": "shift_label",
"table_name": "shift_label",
"endpoint": {
"data_selector": "data",
"path": "/shift-labels",
"params": {
"range_start_date": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_date": "FILL_ME_IN", # TODO: fill in required query parameter
},
}
},
# Time Clock records for the requested date/time range. If a member is clocked in at the time of the request, the time clock record will be excluded.
{
"name": "time_clock_time",
"table_name": "time_clock_time",
"endpoint": {
"data_selector": "data",
"path": "/time-clock-time",
"params": {
"range_start_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
},
}
},
# Approved and pending Time Off ranges for the requested date/time range. Note: By default, only approved Time Off ranges are included in the response.
{
"name": "time_off",
"table_name": "time_off",
"endpoint": {
"data_selector": "data",
"path": "/time-off",
"params": {
"range_start_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
"range_stop_datetime": "FILL_ME_IN", # TODO: fill in required query parameter
# the parameters below can optionally be configured
# "statuses": "approved",
# "daily_split_time": "OPTIONAL_CONFIG",
},
}
},
# Returns a list of unique Time Types which can be applied to scheduled time.
{
"name": "time_type",
"table_name": "time_type",
"endpoint": {
"data_selector": "data",
"path": "/time-types",
}
},
# Returns all active Time Off Types.
{
"name": "type",
"table_name": "type",
"endpoint": {
"data_selector": "data",
"path": "/time-off/types",
}
},
# Returns all work groups. Work groups are used for putting members into groups if they follow the same schedule and work limit rules. Work groups can be customized per Aladtec system.
{
"name": "work_group",
"table_name": "work_group",
"endpoint": {
"data_selector": "data",
"path": "/work-groups",
}
},
]
}
return rest_api_source(source_config)
2. Configuring your source and destination credentials
dlt-init-openapi
will try to detect which authentication mechanism (if any) is used by the API in question and add a placeholder in your secrets.toml
.
The dlt
cli will have created a .dlt
directory in your project folder. This directory contains a config.toml
file and a secrets.toml
file that you can use to configure your pipeline. The automatically created version of these files look like this:
generated config.toml
[runtime]
log_level="INFO"
[sources.aladtec]
# Base URL for the API
base_url = "https://..." # Replace with API base URL
generated secrets.toml
[sources.aladtec]
# secrets for your aladtec source
token = "FILL ME OUT" # TODO: fill in your credentials
2.1. Adjust the generated code to your usecase
At this time, the dlt-init-openapi
cli tool will always create pipelines that load to a local duckdb
instance. Switching to a different destination is trivial, all you need to do is change the destination
parameter in aladtec_pipeline.py
to mssql and supply the credentials as outlined in the destination doc linked below.
3. Running your pipeline for the first time
The dlt
cli has also created a main pipeline script for you at aladtec_pipeline.py
, as well as a folder aladtec
that contains additional python files for your source. These files are your local copies which you can modify to fit your needs. In some cases you may find that you only need to do small changes to your pipelines or add some configurations, in other cases these files can serve as a working starting point for your code, but will need to be adjusted to do what you need them to do.
The main pipeline script will look something like this:
import dlt
from aladtec import aladtec_source
if __name__ == "__main__":
pipeline = dlt.pipeline(
pipeline_name="aladtec_pipeline",
destination='duckdb',
dataset_name="aladtec_data",
progress="log",
export_schema_path="schemas/export"
)
source = aladtec_source()
info = pipeline.run(source)
print(info)
Provided you have set up your credentials, you can run your pipeline like a regular python script with the following command:
python aladtec_pipeline.py
4. Inspecting your load result
You can now inspect the state of your pipeline with the dlt
cli:
dlt pipeline aladtec_pipeline info
You can also use streamlit to inspect the contents of your Microsoft SQL Server
destination for this:
# install streamlit
pip install streamlit
# run the streamlit app for your pipeline with the dlt cli:
dlt pipeline aladtec_pipeline show
5. Next steps to get your pipeline running in production
One of the beauties of dlt
is, that we are just a plain Python library, so you can run your pipeline in any environment that supports Python >= 3.8. We have a couple of helpers and guides in our docs to get you there:
The Deploy section will show you how to deploy your pipeline to
- Deploy with GitHub Actions: Learn how to deploy your
dlt
pipeline using GitHub Actions. - Deploy with Airflow: Follow this guide to deploy your
dlt
pipeline using Airflow and Google Composer. - Deploy with Google Cloud Functions: Discover how to deploy your
dlt
pipeline using Google Cloud Functions. - Explore other deployment options: Check out additional resources on deploying your
dlt
pipeline here.
The running in production section will teach you about:
- How to Monitor your pipeline: Learn how to effectively monitor your
dlt
pipeline in production to ensure smooth operation and timely identification of issues. Read more - Set up alerts: Set up alerts to get notified about important events and potential issues in your
dlt
pipeline. Read more - And set up tracing: Implement tracing to get detailed insights into the execution and performance of your
dlt
pipeline. Read more
Available Sources and Resources
For this verified source the following sources and resources are available
Source Aladtec
Aladtec source for workforce management data including schedules, time clocks, payroll, and employee details.
Resource Name | Write Disposition | Description |
---|---|---|
time_clock_time | append | Tracks the time entries for employees clocking in and out. |
time_off | append | Manages employee time-off requests and approvals. |
availability | append | Records the availability of employees for scheduling purposes. |
position_qualification | append | Details the qualifications required for specific positions. |
schedule | append | Contains the scheduling information for all employees. |
clocked_in_member | append | Lists employees currently clocked in. |
note | append | Stores notes related to scheduling and workforce management. |
open_time | append | Tracks open time slots that need to be filled. |
accrual_bank | append | Manages the accruals of employee benefits like vacation or sick time. |
payroll | append | Contains payroll-related data for employees. |
work_group | append | Defines groups of employees working together. |
extra_hour | append | Tracks extra hours worked by employees. |
members_scheduled_now | append | Lists members who are currently scheduled to work. |
event | append | Records events related to scheduling and workforce management. |
time_type | append | Categorizes different types of time entries (e.g., regular, overtime). |
kiosk | append | Manages data related to kiosk interactions for clocking in/out. |
paycode | append | Defines pay codes used in payroll processing. |
scheduled_time | append | Contains details of scheduled work times for employees. |
shift_label | append | Labels used to categorize different shifts. |
custom_attribute | append | Stores custom attributes for employees or scheduling. |
balance | append | Tracks the balance of various accruals for employees. |
type | append | Defines different types of entities within the system. |
employee_type | append | Categorizes employees by type (e.g., full-time, part-time). |
configuration | append | Stores system configuration settings. |
member | append | Contains detailed information about each employee. |
Additional pipeline guides
- Load data from Fivetran to Snowflake in python with dlt
- Load data from Shopify to ClickHouse in python with dlt
- Load data from Chargebee to BigQuery in python with dlt
- Load data from Apple App-Store Connect to AWS S3 in python with dlt
- Load data from Clubhouse to CockroachDB in python with dlt
- Load data from ClickHouse Cloud to Microsoft SQL Server in python with dlt
- Load data from PostgreSQL to Neon Serverless Postgres in python with dlt
- Load data from Rest API to EDB BigAnimal in python with dlt
- Load data from Attio to DuckDB in python with dlt
- Load data from Slack to Google Cloud Storage in python with dlt