{"id":36986212,"url":"https://github.com/sectsect/google-spreadsheet-to-db","last_synced_at":"2026-01-13T23:04:09.541Z","repository":{"id":38109320,"uuid":"98099393","full_name":"sectsect/google-spreadsheet-to-db","owner":"sectsect","description":"Integrates Google Sheets API to fetch data and store it in a WordPress database - An alternative to CSV Import","archived":false,"fork":false,"pushed_at":"2025-08-24T05:55:09.000Z","size":3583,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T20:55:55.156Z","etag":null,"topics":["csv-import","google-api","google-spreadsheet","sheets-api","spreadsheet","wordpress","wordpress-plugin","wpdb"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sectsect.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2017-07-23T13:22:18.000Z","updated_at":"2025-10-03T22:22:05.000Z","dependencies_parsed_at":"2023-11-11T11:24:48.369Z","dependency_job_id":"27b3f837-ef85-4ef2-8bec-47fdb7dcf060","html_url":"https://github.com/sectsect/google-spreadsheet-to-db","commit_stats":{"total_commits":174,"total_committers":3,"mean_commits":58.0,"dds":"0.13218390804597702","last_synced_commit":"337e5deee3b9578c43a85fd6e56c1e3b2179665d"},"previous_names":[],"tags_count":73,"template":false,"template_full_name":null,"purl":"pkg:github/sectsect/google-spreadsheet-to-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sectsect%2Fgoogle-spreadsheet-to-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sectsect%2Fgoogle-spreadsheet-to-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sectsect%2Fgoogle-spreadsheet-to-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sectsect%2Fgoogle-spreadsheet-to-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sectsect","download_url":"https://codeload.github.com/sectsect/google-spreadsheet-to-db/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sectsect%2Fgoogle-spreadsheet-to-db/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-import","google-api","google-spreadsheet","sheets-api","spreadsheet","wordpress","wordpress-plugin","wpdb"],"created_at":"2026-01-13T23:04:08.717Z","updated_at":"2026-01-13T23:04:09.525Z","avatar_url":"https://github.com/sectsect.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"https://github-sect.s3-ap-northeast-1.amazonaws.com/logo.svg\" width=\"18\" height=\"auto\"\u003e Google Spreadsheet to DB\n[![Plugin Check](https://github.com/sectsect/google-spreadsheet-to-db/actions/workflows/plugin-check.yml/badge.svg)](https://github.com/sectsect/google-spreadsheet-to-db/actions/workflows/plugin-check.yml) [![PHP Unit Tests](https://github.com/sectsect/google-spreadsheet-to-db/actions/workflows/phpunit.yml/badge.svg)](https://github.com/sectsect/google-spreadsheet-to-db/actions/workflows/phpunit.yml) [![PHPStan](https://github.com/sectsect/google-spreadsheet-to-db/actions/workflows/phpstan.yml/badge.svg)](https://github.com/sectsect/google-spreadsheet-to-db/actions/workflows/phpstan.yml) [![PHP Coding Standards](https://github.com/sectsect/google-spreadsheet-to-db/actions/workflows/phpcs.yml/badge.svg)](https://github.com/sectsect/google-spreadsheet-to-db/actions/workflows/phpcs.yml) [![Latest Stable Version](https://poser.pugx.org/sectsect/google-spreadsheet-to-db/v)](//packagist.org/packages/sectsect/google-spreadsheet-to-db)\n\n### The \"Google Spreadsheet to DB\" plugin is designed for WordPress and facilitates the import of data from Google Sheets into a WordPress database using Google's [Sheets API](https://developers.google.com/sheets/api) (v4). It supports data manipulation before saving and is configurable via a WordPress admin interface.\n\n## Features\n- Data Import: Pulls data from Google Sheets and saves it directly into the WordPress database.\n- Customization: Offers settings for defining constants, spreadsheet IDs, names, and configuring data formats.\n- Admin Interface: Provides an admin page for easy management and configuration of the plugin settings.\n\n## Requirements\n- PHP version 8.0 or higher.\n- [Composer](https://getcomposer.org/) for managing PHP dependencies.\n\n## Get Started\n\n##### 1. Clone this Repo into your `wp-content/plugins` directory.\n```sh\ncd /path-to-your/wp-content/plugins/\ngit clone git@github.com:sectsect/google-spreadsheet-to-db.git\n```\n\n##### 2. Remove `vendor/` in `.gitignore` file.\n```sh\ncd google-spreadsheet-to-db\nnano .gitignore\n```\n\n```diff\n- vendor/\n```\n\n##### 3. Install composer packages\n```sh\ncd functions/composer/\ncomposer install\n```\n\n##### 4. Activate the plugin through the 'Plugins' menu in WordPress.\n\n## Settings\n\n### Getting Your Spreadsheet Ready for Programmatic Access\n\nBy default, a new spreadsheet cannot be accessed via Google’s API. We’ll need to go to your Google APIs console and create a new project and set it up to expose your Spreadsheets’ data.\n\n1. Go to the [Google APIs Console](https://console.developers.google.com/).\n2. Create a new project.\n3. Click Enable API. Search for and enable the Google Sheets API.\n4. Create credentials for a Web Server to access Application Data.\n5. Name the service account and grant it a Project Role of Editor.\n6. Download the JSON file.\n7. Copy the JSON file to your app directory and rename it to `client_secret.json`\n8. :warning: Set `client_secret.json` in a location to deny web access on your server.\n\nWe now have a big chunk of authentication information, including what Google calls a `client_email`, which uniquely represents this OAuth service account.  \nGrab the value of `client_email` from your `client_secret.json`, and head back to your spreadsheet. Click the Share button in the top right, and paste the `client_email` value into the field to give it edit rights.  \nHit send. That’s it! :ok_hand:\n\n\n1. Set the `define()` constants for client_secret.json in \u003ccode\u003ewp-config.php\u003c/code\u003e.\n  ```php\n  define( 'GOOGLE_SS2DB_CLIENT_SECRET_PATH', '/path/to/your/client_secret.json' );\n  ```\n2. Go to `Settings` -\u003e `Google Spreadsheet to DB` on your WordPress Admin-Panel.\n3. Set the following values and save it once.\n  - Data format to be stored in database\n    - json_encode\n    - json_encode (JSON_UNESCAPED_UNICODE)\n4. Click the `Import from Google Spreadsheet` button. :tada:\n  - Spreadsheet ID\n  - Spreadsheet name (Optional)\n  - Single Sheet name\n  - Top Header Row\n  - Title (Optional)\n\n## Filters\n\n### Filtering the Array\n\nYou can edit the array got from Google API with `add_filter( 'google_ss2db_before_save', $function_to_add )` in your functions.php before saving to database.\n\n```php\nadd_filter( 'google_ss2db_before_save', function ( $row, $worksheet_id, $worksheet_name, $sheet_name ) {\n  // Example\n  if ( $worksheet_name === 'My Spreadsheet' \u0026\u0026 $sheet_name === 'Sheet1' ) {\n    // Do something.\n\n    return $something;\n  }\n\n  return $row;\n}, 10, 3 );\n```\n\nAnd also use `add_filter('google_ss2db_after_save', $return_array )` to perform any processing with the return value.\n```php\nadd_filter( 'google_ss2db_after_save', function ( $data ) {\n  if ( 'My Spreadsheet' === $data['worksheet_name'] ) {\n    // $id              = $data['id'];\n    // $date            = $data['date'];\n    // $title           = $data['title'];\n    // $value           = $data['value'];\n    // $work_sheet_id   = $data['worksheet_id'];\n    // $work_sheet_name = $data['worksheet_name'];\n    // $sheet_name      = $data['sheet_name'];\n    // $result          = $data['result']; // `int|false` The number of rows inserted, or false on error.\n\n    // Example\n    my_callback( $data );\n  }\n});\n```\n\n## APIs\n\n```php\nnew Google_Spreadsheet_To_DB_Query();\n```\n\n#### Parameters\n\n| Parameter |          |         | Type   | Notes                                      | Default Value |\n| --------- | -------- | ------- | ------ | ------------------------------------------ | ------------- |\n| where     |          |         | array  |                                            | `array()`     |\n|           | relation |         | string | `AND` or `OR`                              |  `AND`        |\n|           | [array]  |         | array  |                                            |               |\n|           |          | key     | string | `id` or `date` or `worksheet_id` or `worksheet_name` or `sheet_name` or `title` |  `false`      |\n|           |          | value   | int    | e.g. `3` / `2020-09-01 12:00:00`           |  `false`      |\n|           |          | compare | string | e.g. `=`  `\u003e`  `\u003c`  `\u003e=`  `\u003c=`  `\u003c\u003e`  `!=` |  `=`          |\n| orderby   |          |         | string | `id` or `date` or `worksheet_id` or `worksheet_name` or `sheet_name` or `title` | `date`        |\n| order     |          |         | string | `DESC` or `ASC`                            | `DESC`        |\n| limit     |          |         | int    | number of row to get                       | All Data\u003cbr\u003e:memo: You can also use `-1` to get all data. |\n| offset    |          |         | int    | number of row to displace or pass over     | `0`           |\n\n## Usage Example\n\n#### Get all rows\n```php\n$sheet = new Google_Spreadsheet_To_DB_Query();\n$rows  = $sheet-\u003egetrow();\nforeach ( $rows as $row ) {\n  $id   = $row-\u003eid;\n  $date = $row-\u003edate;\n  $val  = json_decode( $row-\u003evalue );\n}\n```\n\n#### Get 3 rows from the 4th in ascending order by ID\n```php\n$args = array(\n  'orderby' =\u003e 'id',\n  'order'   =\u003e 'ASC',\n  'limit'   =\u003e 3,\n  'offset'  =\u003e 3,\n);\n$sheet = new Google_Spreadsheet_To_DB_Query( $args );\n$rows  = $sheet-\u003egetrow();\nforeach ( $rows as $row ) {\n  $id   = $row-\u003eid;\n  $date = $row-\u003edate;\n  $val  = json_decode( $row-\u003evalue );\n}\n```\n\n#### Get the row with specific ID\n```php\n$args = array(\n  'where' =\u003e array(\n    array(\n      'key'   =\u003e 'id',\n      'value' =\u003e 3,\n    )\n  ),\n);\n```\n\n#### Get 3 rows with specific Worksheet ordered by ID\n```php\n$args = array(\n  'orderby' =\u003e 'id',\n  'order'   =\u003e 'ASC',\n  'limit'   =\u003e 3,\n  'where'   =\u003e array(\n    array(\n      'key'     =\u003e 'worksheet_name',\n      'value'   =\u003e 'My Spreadsheet',\n      'compare' =\u003e '='\n    ),\n  ),\n);\n```\n\n#### Get the rows larger than or equal the specified datetime\n```php\n$args = array(\n  'where' =\u003e array(\n    array(\n      'key'     =\u003e 'date',\n      'value'   =\u003e '2020-08-01 12:34:56',\n      'compare' =\u003e '\u003e=',\n    )\n  ),\n);\n```\n\n#### Get the rows with multiple conditions\n```php\n$args = array(\n  'orderby' =\u003e 'id',\n  'order'   =\u003e 'DESC',\n  'limit'   =\u003e 10,\n  'offset'  =\u003e 10,\n  'where'   =\u003e array(\n    'relation' =\u003e 'AND', // or 'OR'\n    array(\n      'key'     =\u003e 'date',\n      'value'   =\u003e '2020-08-01 12:34:56',\n      'compare' =\u003e '\u003e='\n    ),\n    array(\n      'key'     =\u003e 'worksheet_name',\n      'value'   =\u003e 'My Spreadsheet',\n      'compare' =\u003e '='\n    ),\n  ),\n);\n```\n\n## Notes\n\n* Tested on WordPress v6.3.1\n\n## For Developers\n\n* This plugin saves Spreadsheet's data to the global area, not to each post. If you want to have Spredsheet data for individual posts, you can link data `ID` with custom fields.\n* The data is added and stored in the `wp_google_ss2db` table as a JSON-encoded array.\n\n  \u003ctable\u003e\n  \u003cthead\u003e\n  \u003ctr\u003e\n  \u003cth\u003eid\u003c/th\u003e\n  \u003cth\u003edate\u003c/th\u003e\n  \u003cth\u003eworksheet_id\u003c/th\u003e\n  \u003cth\u003eworksheet_name\u003c/th\u003e\n  \u003cth\u003esheet_name\u003c/th\u003e\n  \u003cth\u003etitle\u003c/th\u003e\n  \u003cth\u003evalue\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n  \u003ctr\u003e\n  \u003ctd\u003e1\u003c/td\u003e\n  \u003ctd\u003e2021-08-27 00:00:00\u003c/td\u003e\n  \u003ctd\u003e1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms\u003c/td\u003e\n  \u003ctd\u003eMy Spreadsheet\u003c/td\u003e\n  \u003ctd\u003eSheet1\u003c/td\u003e\n  \u003ctd\u003eData-01\u003c/td\u003e\n  \u003ctd\u003e\u003ccode style=\"word-break: break-all;\"\u003e{\"area\":{\"a\":[\"brooklyn\",\"bronx\",\"Queens\",\"Manhattan\"],\"b\":[\"brooklyn\",\"bronx\",\"Queens\",\"Manhattan\"]}}\u003c/code\u003e\u003c/td\u003e\n  \u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\n\n* This Plugin does not hosting on the [wordpress.org](https://wordpress.org/) repo in order to prevent a flood of support requests from wide audience.\n\n## Debug Mode\n\nTo enable debug mode, add the following constant to your `wp-config.php`:\n\n```php\ndefine( 'GOOGLE_SS2DB_DEBUG', true );\n```\n\nWhen debug mode is enabled, importing a spreadsheet will return a detailed JSON response instead of the usual redirect. The response includes the following information:\n\n- `result`: A boolean indicating the success or failure of the process\n- `data`: Details of the saved data\n- `post_data`: Sanitized post data\n- `referer`: The redirect URL\n\n**Note**: Always set `GOOGLE_SS2DB_DEBUG` to `false` or remove the constant in production environments.\n\n## Troubleshooting\n\nThis plugin depends on [Guzzle](https://github.com/guzzle/guzzle) **v7**, which may conflict with other WordPress plugins or Composer packages using Guzzle **v6**.  \nIf you encounter errors like:\n\n\u003e `Uncaught Error: Call to undefined method GuzzleHttp\\Utils::chooseHandler()`\n\nThis is likely due to a Guzzle version conflict. To resolve:\n1. Update other plugins/packages to versions compatible with Guzzle v7\n2. Find alternative solutions that don't conflict with this plugin's dependencies\n\n## Change log  \n\nSee [CHANGELOG](https://github.com/sectsect/google-spreadsheet-to-db/blob/master/CHANGELOG.md) file.\n\n## License\n\nSee [LICENSE](https://github.com/sectsect/google-spreadsheet-to-db/blob/master/LICENSE) file.\n\n\u003cp align=\"center\"\u003e✌️\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003csub\u003e\u003csup\u003eA little project by \u003ca href=\"https://github.com/sectsect\"\u003e@sectsect\u003c/a\u003e\u003c/sup\u003e\u003c/sub\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsectsect%2Fgoogle-spreadsheet-to-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsectsect%2Fgoogle-spreadsheet-to-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsectsect%2Fgoogle-spreadsheet-to-db/lists"}