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())

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.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distributions

wpdatabase2-0.0.1-py3.7.egg (22.3 kB view details)

Uploaded Source

wpdatabase2-0.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wpdatabase2-0.0.1.tar.gz
  • Upload date:
  • Size: 8.3 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.1.tar.gz
Algorithm Hash digest
SHA256 f1acfcc16e5ec837031a7a3ca3678e18db2e763b3552ccdfabb46a94f83b0edf
MD5 cabe9d38c3dc3a411847db9c9faecdd0
BLAKE2b-256 1ead5d8f77b94363f60c3b6c4bea208bdbfbf98426e4259844d19ae81deb06e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wpdatabase2-0.0.1-py3.7.egg
  • Upload date:
  • Size: 22.3 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.1-py3.7.egg
Algorithm Hash digest
SHA256 c9138c271515f72171215dca6b970bed6dd5e5c59d98e53f288ee2814eaa2c32
MD5 dde892e202a8b246462ebdedc992b50f
BLAKE2b-256 429eb0ba454870d3dd7e681d019b3c630e5ddbf527883c970a49f77b72ca4770

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wpdatabase2-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e07159eaa1d33c5d99fa680cee18c156e63a9a8a451be4bfa2c427651335a50c
MD5 4d1476acf5d677fb7f10bff759415e81
BLAKE2b-256 ebf1f2ab8f6b1e5e1fb0591bee00823cd643fa49cbd55ec3d0c18f23543c3383

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