Skip to main content

A Python package that checks and/or sets up a WordPress database.

Project description

py-wordpress-database

CircleCI

A big call out to @cariad for the original version of this library

A Python package that sets up a WordPress database.

wpdatabase2 will:

  • Provide a way to check to see if the wordpress database already exists
  • Return the version details of the wordpress database (if it exists)
  • Create the database, if it doesn't exist already.
  • Create the WordPress user, if it doesn't exist already.

wpdatabase2 is idempotent; if the database and the user already exist then it will return successfully.

Note that wpdatabase2 currently only supports MySQL databases.

Installation

pip install wpdatabase2

Prerequisites

wpdatabase2 assumes that the following properties have already been set in the wp-config.php file:

Property Description
DB_HOST Host or endpoint of the MySQL database server.
DB_USER WordPress database user.
DB_PASSWORD WordPress database password.

If you need help adding these values to wp-config.php then check out wpconfigr.

Command-line usage

If you need to specify to the database's administrator username and password:

python -m wpdatabase2 
        --wp-config      /www/wp-config.php \
        --admin-username garnet \
        --admin-password love

If you're deploying WordPress into Amazon Web Services (AWS) and have your administrator username and password held in Secrets Manager:

python -m wpdatabase2 
        --wp-config                       /www/wp-config.php \
        --admin-credentials-aws-secret-id AdminSecretID \
        --admin-credentials-aws-region    eu-west-1

Library usage

import wpdatabase2

wpdb = WpDatabase('path to wp-config.php')
print(wpdb.get_database_version())

Development

To install development dependencies:

pip install -e .[dev]

To run the tests:

python test.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wpdatabase2-0.0.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distributions

wpdatabase2-0.0.2-py3.7.egg (23.2 kB view details)

Uploaded Source

wpdatabase2-0.0.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file wpdatabase2-0.0.2.tar.gz.

File metadata

  • Download URL: wpdatabase2-0.0.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5

File hashes

Hashes for wpdatabase2-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4a713fcff572734e400180a69a5b96e958157eef924bdee625922bd0d18b9442
MD5 8c6c3fe6f8476289db1470c5fe6e1be5
BLAKE2b-256 074f3249fe38333d34779649124a5807f275a5df6f2bc0ad7117b256fcb53630

See more details on using hashes here.

File details

Details for the file wpdatabase2-0.0.2-py3.7.egg.

File metadata

  • Download URL: wpdatabase2-0.0.2-py3.7.egg
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5

File hashes

Hashes for wpdatabase2-0.0.2-py3.7.egg
Algorithm Hash digest
SHA256 ba9aa43651be21f5d385fc22500e77936d99d304402535b3c5aa1c4cbcf10887
MD5 92d50463ea9482abf0a70fcbf97fb5fe
BLAKE2b-256 09f27f7ca4b6ffaba1ff29d60d79affd2e3ad8c9345fc39ca71ab87aa22b5214

See more details on using hashes here.

File details

Details for the file wpdatabase2-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: wpdatabase2-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5

File hashes

Hashes for wpdatabase2-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1b7fb2e7047cd22b036a46bde398005fb99a5a8b4f6bf7edcc717701514d7979
MD5 2748b66df5c512c7e594d874881ffb14
BLAKE2b-256 912f85c6e450239bd4ba180f0c2896dadbe4c94accb0d207295825ac40021bdf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page