Converts a WordPress database to a Python dictionary, using WP-CLI's `wp db query` command.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
wpdb2dict
.editorconfig
.gitattributes
.gitignore
LICENSE
README.rst
setup.py

README.rst

wpdb2dict

Converts a WordPress database to a Python dictionary, using WP-CLI's "wp db query" command.

Installation

To install, use pip:

$ pip install wpdb2dict

Usage

Print:

$ python /path/to/wpdb2dict.py --path=/path/to/wp --url=https://example.com

Export to file:

$ python /path/to/wpdb2dict.py --path=/path/to/wp --url=https://example.com > wpdb2dict.txt

Example output

import pprint
pprint.pprint(data['wp_posts']['1'])
{'ID': '1',
 'comment_count': '1',
 'comment_status': 'open',
 'guid': 'https://example.com/?p=1',
 'menu_order': '0',
 'ping_status': 'open',
 'pinged': '',
 'post_author': '1',
 'post_content': 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!',
 'post_content_filtered': '',
 'post_date': '2017-02-26 09:25:33',
 'post_date_gmt': '2017-02-26 08:25:33',
 'post_excerpt': '',
 'post_mime_type': '',
 'post_modified': '2017-02-26 09:25:33',
 'post_modified_gmt': '2017-02-26 08:25:33',
 'post_name': 'hello-world',
 'post_parent': '0',
 'post_password': '',
 'post_status': 'publish',
 'post_title': 'Hello world!',
 'post_type': 'post',
 'to_ping': ''}

License

This script was released under the MIT license.