{"id":23468198,"url":"https://github.com/camilajaviera91/sql-to-googlesheets","last_synced_at":"2026-03-02T19:34:34.115Z","repository":{"id":264972297,"uuid":"894783789","full_name":"CamilaJaviera91/sql-to-googlesheets","owner":"CamilaJaviera91","description":"This repository provides a set of scripts to extract data from a MySQL database, transform it into a CSV file, and integrate it with Google Sheets. The workflow includes database connection, querying, data transformation, and file generation.","archived":false,"fork":false,"pushed_at":"2025-01-03T14:01:49.000Z","size":164,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-03T15:19:38.931Z","etag":null,"topics":["csv","googlesheets","googlesheetsapi","lookerstudio","mysql","python","sql"],"latest_commit_sha":null,"homepage":"","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/CamilaJaviera91.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-11-27T01:34:04.000Z","updated_at":"2025-01-03T14:01:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"e79a6fd3-fb98-4535-b1c6-4cb465501c77","html_url":"https://github.com/CamilaJaviera91/sql-to-googlesheets","commit_stats":null,"previous_names":["camilajaviera91/sql-to-googlesheets"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamilaJaviera91%2Fsql-to-googlesheets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamilaJaviera91%2Fsql-to-googlesheets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamilaJaviera91%2Fsql-to-googlesheets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamilaJaviera91%2Fsql-to-googlesheets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CamilaJaviera91","download_url":"https://codeload.github.com/CamilaJaviera91/sql-to-googlesheets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240599181,"owners_count":19826959,"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":["csv","googlesheets","googlesheetsapi","lookerstudio","mysql","python","sql"],"created_at":"2024-12-24T13:38:54.970Z","updated_at":"2026-03-02T19:34:29.069Z","avatar_url":"https://github.com/CamilaJaviera91.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL and Google Sheets Data Integration\n\nThis repository provides a set of scripts to extract data from a MySQL database, transform it into a CSV file, and integrate it with Google Sheets. The workflow includes database connection, querying, data transformation, and file generation.\n\n## Files Overview\n\n### 1. `connect_mysql.py`\n- Establishes a connection to a MySQL database.\n- Allows querying and data manipulation.\n- Key functions:\n  - `connect_mysql`: Connects to the database and returns a connection object.\n\n### 2. `credentials.py`\n- Manages Google API credentials for accessing Google Sheets.\n- Key functions:\n  - `credentials`: Loads credentials from a JSON file and returns an authenticated credentials object.\n\n### 3. `id_spreadsheets.py`\n- Stores and retrieves the Google Sheets ID for interaction.\n- Key functions:\n  - `spreadsheets`: Returns the Google Sheets ID.\n\n### 4. `queries.py`\n- Defines and executes SQL queries on the connected MySQL database.\n- Key functions:\n  - `amounts_quantity`: Retrieves data about vehicle circulation permits, including vehicle details, payment type, and service module.\n\n### 5. `sql_to_csv.py`\n- Converts query results into a CSV file.\n- Key functions:\n  - `sql_to_csv`: Transforms SQL query results into a CSV file named `vehicle_circulation_permit.csv`.\n\n## Prerequisites\n\n1. **Python 3.7 or higher**\n2. **Dependencies**\n   Install required libraries:\n   ```bash\n   pip install pymysql pandas google-auth google-auth-oauthlib\n   ```\n\n3. **Google API Credentials**\n   - Obtain a credentials JSON file from the Google Cloud Console.\n   - Save it as `credentials.json` in the project directory.\n\n4. **MySQL Database**\n   - Ensure your database server is running and the credentials are correct in `connect_mysql.py`.\n\n## Usage\n\n### 1. **Connect to MySQL Database**\n   - Update the `connect_mysql` function in `connect_mysql.py` with your database details.\n\n### 2. **Configure Google Sheets**\n   - Replace the `SPREADSHEET_ID` in `id_spreadsheets.py` with your Google Sheets ID.\n\n### 3. **Execute Queries**\n   - Use `queries.py` to define and execute your SQL queries.\n   - Example:\n     ```python\n     from queries import amounts_quantity\n     data = amounts_quantity()\n     print(data)\n     ```\n\n### 4. **Generate CSV File**\n   - Run `sql_to_csv.py` to save query results as a CSV file.\n   - Example:\n     ```bash\n     python sql_to_csv.py\n     ```\n   - Output: `vehicle_circulation_permit.csv`\n\n## Project Structure\n\n```plaintext\n.\n├── connect_mysql.py\n├── credentials.py\n├── id_spreadsheets.py\n├── queries.py\n├── sql_to_csv.py\n├── credentials.json\n├── vehicle_circulation_permit.csv\n└── README.md\n```\n\n## Notes\n- Ensure your MySQL server is accessible and credentials are correct.\n- For Google Sheets, verify API permissions and access.\n- Modify queries in `queries.py` as per your database structure and requirements.\n\n## Contributions\nContributions are welcome! Feel free to open an issue or submit a pull request for improvements.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamilajaviera91%2Fsql-to-googlesheets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcamilajaviera91%2Fsql-to-googlesheets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamilajaviera91%2Fsql-to-googlesheets/lists"}