# flake8: noqa import humanize from typing import Any import os import dlt from dlt.common import pendulum from dlt.sources.credentials import ConnectionStringCredentials from dlt.sources.sql_database import sql_database, sql_table, Table from sqlalchemy.sql.sqltypes import TypeEngine import sqlalchemy as sa def load_select_tables_from_database() -> None: """Use the sql_database source to reflect an entire database schema and load select tables from it. This example sources data from the public Rfam MySQL database. """ # Create a pipeline pipeline = dlt.pipeline( pipeline_name="mysql_test", destination='bigquery', dataset_name="raw_mysql_data",) credentials = ConnectionStringCredentials( "mysql+pymysql://pchubapp:7CRJbnVis_Ls@34.150.22.222:3306/pchub_app" ) # Configure the source to load a few select tables incrementally source_1 = sql_database().with_resources("cloud_resource") # Run the pipeline. The merge write disposition merges existing rows in the destination by primary key info = pipeline.run(source_1) print(info) if __name__ == "__main__": # Load selected tables with different settings load_select_tables_from_database()