PHPackages                             sectsect/google-spreadsheet-to-db - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sectsect/google-spreadsheet-to-db

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

sectsect/google-spreadsheet-to-db
=================================

Pulls Google Spreadsheet data via Google’s API and saves it in your wordpress database.

v6.12.0(2mo ago)7141[4 PRs](https://github.com/sectsect/google-spreadsheet-to-db/pulls)GPL-3.0+PHPPHP &gt;=8.0CI passing

Since Jul 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/sectsect/google-spreadsheet-to-db)[ Packagist](https://packagist.org/packages/sectsect/google-spreadsheet-to-db)[ RSS](/packages/sectsect-google-spreadsheet-to-db/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (9)Versions (83)Used By (0)

[![](https://camo.githubusercontent.com/b8a22d292780c631360a84efd912e57855d5395021965174bffa6f3b255dd62f/68747470733a2f2f6769746875622d736563742e73332d61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f6c6f676f2e737667)](https://camo.githubusercontent.com/b8a22d292780c631360a84efd912e57855d5395021965174bffa6f3b255dd62f/68747470733a2f2f6769746875622d736563742e73332d61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f6c6f676f2e737667) Google Spreadsheet to DB
==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#-google-spreadsheet-to-db)

[![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://camo.githubusercontent.com/5bc3b67930c9abfab9fbf0224caa0f575cc083d13ea6d0af60d16911ee2f30b6/68747470733a2f2f706f7365722e707567782e6f72672f73656374736563742f676f6f676c652d73707265616473686565742d746f2d64622f76)](//packagist.org/packages/sectsect/google-spreadsheet-to-db)

### 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.

[](#the-google-spreadsheet-to-db-plugin-is-designed-for-wordpress-and-facilitates-the-import-of-data-from-google-sheets-into-a-wordpress-database-using-googles-sheets-api-v4-it-supports-data-manipulation-before-saving-and-is-configurable-via-a-wordpress-admin-interface)

Features
--------

[](#features)

- Data Import: Pulls data from Google Sheets and saves it directly into the WordPress database.
- Customization: Offers settings for defining constants, spreadsheet IDs, names, and configuring data formats.
- Admin Interface: Provides an admin page for easy management and configuration of the plugin settings.

Requirements
------------

[](#requirements)

- PHP version 8.0 or higher.
- [Composer](https://getcomposer.org/) for managing PHP dependencies.

Get Started
-----------

[](#get-started)

##### 1. Clone this Repo into your `wp-content/plugins` directory.

[](#1-clone-this-repo-into-your-wp-contentplugins-directory)

```
cd /path-to-your/wp-content/plugins/
git clone git@github.com:sectsect/google-spreadsheet-to-db.git
```

##### 2. Remove `vendor/` in `.gitignore` file.

[](#2-remove-vendor-in-gitignore-file)

```
cd google-spreadsheet-to-db
nano .gitignore
```

```
- vendor/
```

##### 3. Install composer packages

[](#3-install-composer-packages)

```
cd functions/composer/
composer install
```

##### 4. Activate the plugin through the 'Plugins' menu in WordPress.

[](#4-activate-the-plugin-through-the-plugins-menu-in-wordpress)

Settings
--------

[](#settings)

### Getting Your Spreadsheet Ready for Programmatic Access

[](#getting-your-spreadsheet-ready-for-programmatic-access)

By 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.

1. Go to the [Google APIs Console](https://console.developers.google.com/).
2. Create a new project.
3. Click Enable API. Search for and enable the Google Sheets API.
4. Create credentials for a Web Server to access Application Data.
5. Name the service account and grant it a Project Role of Editor.
6. Download the JSON file.
7. Copy the JSON file to your app directory and rename it to `client_secret.json`
8. ⚠️ Set `client_secret.json` in a location to deny web access on your server.

We now have a big chunk of authentication information, including what Google calls a `client_email`, which uniquely represents this OAuth service account.
Grab 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.
Hit send. That’s it! 👌

1. Set the `define()` constants for client\_secret.json in `wp-config.php`.

```
define( 'GOOGLE_SS2DB_CLIENT_SECRET_PATH', '/path/to/your/client_secret.json' );
```

2. Go to `Settings` -&gt; `Google Spreadsheet to DB` on your WordPress Admin-Panel.
3. Set the following values and save it once.

- Data format to be stored in database
    - json\_encode
    - json\_encode (JSON\_UNESCAPED\_UNICODE)

4. Click the `Import from Google Spreadsheet` button. 🎉

- Spreadsheet ID
- Spreadsheet name (Optional)
- Single Sheet name
- Top Header Row
- Title (Optional)

Filters
-------

[](#filters)

### Filtering the Array

[](#filtering-the-array)

You 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.

```
add_filter( 'google_ss2db_before_save', function ( $row, $worksheet_id, $worksheet_name, $sheet_name ) {
  // Example
  if ( $worksheet_name === 'My Spreadsheet' && $sheet_name === 'Sheet1' ) {
    // Do something.

    return $something;
  }

  return $row;
}, 10, 3 );
```

And also use `add_filter('google_ss2db_after_save', $return_array )` to perform any processing with the return value.

```
add_filter( 'google_ss2db_after_save', function ( $data ) {
  if ( 'My Spreadsheet' === $data['worksheet_name'] ) {
    // $id              = $data['id'];
    // $date            = $data['date'];
    // $title           = $data['title'];
    // $value           = $data['value'];
    // $work_sheet_id   = $data['worksheet_id'];
    // $work_sheet_name = $data['worksheet_name'];
    // $sheet_name      = $data['sheet_name'];
    // $result          = $data['result']; // `int|false` The number of rows inserted, or false on error.

    // Example
    my_callback( $data );
  }
});
```

APIs
----

[](#apis)

```
new Google_Spreadsheet_To_DB_Query();
```

#### Parameters

[](#parameters)

ParameterTypeNotesDefault Valuewherearray`array()`relationstring`AND` or `OR``AND`\[array\]arraykeystring`id` or `date` or `worksheet_id` or `worksheet_name` or `sheet_name` or `title``false`valueinte.g. `3` / `2020-09-01 12:00:00``false`comparestringe.g. `=` `>` `=` `getrow();
foreach ( $rows as $row ) {
  $id   = $row->id;
  $date = $row->date;
  $val  = json_decode( $row->value );
}
```

#### Get 3 rows from the 4th in ascending order by ID

[](#get-3-rows-from-the-4th-in-ascending-order-by-id)

```
$args = array(
  'orderby' => 'id',
  'order'   => 'ASC',
  'limit'   => 3,
  'offset'  => 3,
);
$sheet = new Google_Spreadsheet_To_DB_Query( $args );
$rows  = $sheet->getrow();
foreach ( $rows as $row ) {
  $id   = $row->id;
  $date = $row->date;
  $val  = json_decode( $row->value );
}
```

#### Get the row with specific ID

[](#get-the-row-with-specific-id)

```
$args = array(
  'where' => array(
    array(
      'key'   => 'id',
      'value' => 3,
    )
  ),
);
```

#### Get 3 rows with specific Worksheet ordered by ID

[](#get-3-rows-with-specific-worksheet-ordered-by-id)

```
$args = array(
  'orderby' => 'id',
  'order'   => 'ASC',
  'limit'   => 3,
  'where'   => array(
    array(
      'key'     => 'worksheet_name',
      'value'   => 'My Spreadsheet',
      'compare' => '='
    ),
  ),
);
```

#### Get the rows larger than or equal the specified datetime

[](#get-the-rows-larger-than-or-equal-the-specified-datetime)

```
$args = array(
  'where' => array(
    array(
      'key'     => 'date',
      'value'   => '2020-08-01 12:34:56',
      'compare' => '>=',
    )
  ),
);
```

#### Get the rows with multiple conditions

[](#get-the-rows-with-multiple-conditions)

```
$args = array(
  'orderby' => 'id',
  'order'   => 'DESC',
  'limit'   => 10,
  'offset'  => 10,
  'where'   => array(
    'relation' => 'AND', // or 'OR'
    array(
      'key'     => 'date',
      'value'   => '2020-08-01 12:34:56',
      'compare' => '>='
    ),
    array(
      'key'     => 'worksheet_name',
      'value'   => 'My Spreadsheet',
      'compare' => '='
    ),
  ),
);
```

Notes
-----

[](#notes)

- Tested on WordPress v6.3.1

For Developers
--------------

[](#for-developers)

- 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.
- The data is added and stored in the `wp_google_ss2db` table as a JSON-encoded array.

    iddateworksheet\_idworksheet\_namesheet\_nametitlevalue12021-08-27 00:00:001BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upmsMy SpreadsheetSheet1Data-01`{"area":{"a":["brooklyn","bronx","Queens","Manhattan"],"b":["brooklyn","bronx","Queens","Manhattan"]}}`
- 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.

Debug Mode
----------

[](#debug-mode)

To enable debug mode, add the following constant to your `wp-config.php`:

```
define( 'GOOGLE_SS2DB_DEBUG', true );
```

When debug mode is enabled, importing a spreadsheet will return a detailed JSON response instead of the usual redirect. The response includes the following information:

- `result`: A boolean indicating the success or failure of the process
- `data`: Details of the saved data
- `post_data`: Sanitized post data
- `referer`: The redirect URL

**Note**: Always set `GOOGLE_SS2DB_DEBUG` to `false` or remove the constant in production environments.

Troubleshooting
---------------

[](#troubleshooting)

This plugin depends on [Guzzle](https://github.com/guzzle/guzzle) **v7**, which may conflict with other WordPress plugins or Composer packages using Guzzle **v6**.
If you encounter errors like:

> `Uncaught Error: Call to undefined method GuzzleHttp\Utils::chooseHandler()`

This is likely due to a Guzzle version conflict. To resolve:

1. Update other plugins/packages to versions compatible with Guzzle v7
2. Find alternative solutions that don't conflict with this plugin's dependencies

Change log
----------

[](#change-log)

See [CHANGELOG](https://github.com/sectsect/google-spreadsheet-to-db/blob/master/CHANGELOG.md) file.

License
-------

[](#license)

See [LICENSE](https://github.com/sectsect/google-spreadsheet-to-db/blob/master/LICENSE) file.

✌️

A little project by [@sectsect](https://github.com/sectsect)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 98.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Recently: every ~108 days

Total

74

Last Release

79d ago

Major Versions

v1.2.5 → v2.0.02020-07-07

v2.6.0 → v3.0.02021-08-27

v3.3.2 → v4.0.02023-10-09

v4.1.0 → v5.0.02024-04-15

v5.1.0 → v6.0.02024-04-28

PHP version history (2 changes)v1.0.0PHP &gt;=5.5

v6.8.2PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0ad6cda4575e93cf7751cf8d2a13d1d6c9f908e6a61448dfa5f481ca985ec0d?d=identicon)[sectsect](/maintainers/sectsect)

---

Top Contributors

[![sectsect](https://avatars.githubusercontent.com/u/5554826?v=4)](https://github.com/sectsect "sectsect (422 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

csv-importgoogle-apigoogle-spreadsheetsheets-apispreadsheetwordpresswordpress-pluginwpdbpluginwordpressarraygooglespreadsheetgithub

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sectsect-google-spreadsheet-to-db/health.svg)

```
[![Health](https://phpackages.com/badges/sectsect-google-spreadsheet-to-db/health.svg)](https://phpackages.com/packages/sectsect-google-spreadsheet-to-db)
```

###  Alternatives

[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[webdevstudios/cmb2-attached-posts

Custom field for CMB2 for creating post relationships.

13565.5k](/packages/webdevstudios-cmb2-attached-posts)[iceicetimmy/acf-post-type-selector

Post type selector for Advanced Custom Fields.

559.0k](/packages/iceicetimmy-acf-post-type-selector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
