{"id":28240612,"url":"https://github.com/datasherlock/csql-copy-dataflow","last_synced_at":"2025-06-12T09:31:35.747Z","repository":{"id":253826863,"uuid":"844594361","full_name":"datasherlock/csql-copy-dataflow","owner":"datasherlock","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-20T09:09:53.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T04:11:37.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datasherlock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-19T15:18:48.000Z","updated_at":"2024-08-20T09:09:56.000Z","dependencies_parsed_at":"2024-08-21T19:32:28.848Z","dependency_job_id":null,"html_url":"https://github.com/datasherlock/csql-copy-dataflow","commit_stats":null,"previous_names":["datasherlock/csql-copy-dataflow"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/datasherlock/csql-copy-dataflow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datasherlock%2Fcsql-copy-dataflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datasherlock%2Fcsql-copy-dataflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datasherlock%2Fcsql-copy-dataflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datasherlock%2Fcsql-copy-dataflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datasherlock","download_url":"https://codeload.github.com/datasherlock/csql-copy-dataflow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datasherlock%2Fcsql-copy-dataflow/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259438650,"owners_count":22857567,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-19T04:11:36.230Z","updated_at":"2025-06-12T09:31:35.737Z","avatar_url":"https://github.com/datasherlock.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# DataflowToCloudSQL\n#### Developed By: Jerome Rajan, Staff Solutions Consultant, Google\n\n## Overview\n\n`DataflowToCloudSQL` is a Python-based project that integrates Apache Beam pipelines with Google Cloud SQL. \nThe project is structured to allow reading data from a GCS bucket, and writing the results to a GCP CloudSQL Postgres\ndatabase. The primary aim of this repo is to demonstrate connecting to CloudSQL from Dataflow :\n- Using a private IP\n- Using IAM authentication\n- Without a CloudSQL Auth Proxy\n\nThe solution uses SQLAlchemy's bulk loading capabilities in conjunction with Beam's distributed framework. \n\n## Project Structure\n\n- **common/**: Contains common utility modules used across the project.\n  - `config.ini`: Configuration file for storing database connection details and other dataflow configurations.\n  - `get_connection.py`: Module for establishing a connection to Google Cloud SQL.\n  - `Logger.py`: Module for logging throughout the application.\n  - `parse_configs.py`: Handles the parsing of the configuration file (`config.ini`).\n  - `utils.py`: Additional utility functions used across the project.\n\n- **pipelines/**: Directory intended for storing Apache Beam pipeline definitions.\n\n- **sinks/**: Directory intended for modules related to data sinks, such as CloudSQL\n\n- **sources/**: Directory intended for modules related to data sources.\n  - `read_from_source.py`: Module for reading data from the specified source. This is a sample record generator to demonstrate the CloudSQL write capability\n\n- **Dockerfile**: Docker configuration for containerizing the application.\n\n- **main.py**: The main entry point of the application that initializes and runs the Apache Beam pipeline.\n\n- **requirements.txt**: Python dependencies required for the project.\n\n- **setup.py**: Script for installing the project and its dependencies.\n\n## Configuration\n\nThe application uses a `config.ini` file located in the `common/` directory for configuration. This file should contain necessary details such as database credentials, connection strings, and other configurable parameters.\n\nExample `config.ini`:\n\n```ini\n[cloudsql]\ninstance=project:region:cloudsql-instance\ndatabase=postgres\nschema=public\nuser=dataflow-sa@project_name.iam\npassword=''\nbatch=10000\n\n[dataflow]\nproject=project_name\ntemp_location=\"\"\nstaging_location=\"\"\nregion=us-central1\nservice_account=dataflow-sa@project_name.iam.gserviceaccount.com\n\n[source]\nsrc_path=gs://bucket_name/df_big/output*\n```\n\nCopy the config.ini to a GCS path\n```\ngcloud storage cp common/config.ini gs://bucket_name/dataflowtocsql/config/config.ini\n```\n\nTo build image using `gcloud builds` - \n```\ngcloud builds submit --tag us-central1-docker.pkg.dev/project_name/repo_name/dataflow/dataflow2csql:1.0\n```\n\nRun the job with DataflowRunner - \n```\npython main.py --config_path=\"gs://bucket_name/dataflowtocsql/config/config.ini\" --runner=DataflowRunner --sdk_container_image=\"us-central1-docker.pkg.dev/project_name/repo_name/dataflow/dataflow2csql:2.0\" --setup_file=./setup.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatasherlock%2Fcsql-copy-dataflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatasherlock%2Fcsql-copy-dataflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatasherlock%2Fcsql-copy-dataflow/lists"}