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

Uploaded Source

Built Distributions

wpdatabase2-0.0.7-py3.8.egg (23.8 kB view details)

Uploaded Source

wpdatabase2-0.0.7-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wpdatabase2-0.0.7.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for wpdatabase2-0.0.7.tar.gz
Algorithm Hash digest
SHA256 5dda0ea7b954956c4e710a473568e0a48bdc710a16b6b116ea8774cfde126943
MD5 cbdb4e8096817d94cb177b7ce2e19315
BLAKE2b-256 b550c4e43f1b08f1937f3dd7fc43c9945b9241be3b6502a7eac74c369b8c1ed7

See more details on using hashes here.

File details

Details for the file wpdatabase2-0.0.7-py3.8.egg.

File metadata

  • Download URL: wpdatabase2-0.0.7-py3.8.egg
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for wpdatabase2-0.0.7-py3.8.egg
Algorithm Hash digest
SHA256 a501ca5a50308728c848818aa4608156ffee6ddd7f4e2821ee1f813d84a1ed34
MD5 5a3a15a4cee06bf1d22349c24127d454
BLAKE2b-256 05413fd1365a2544604a50207e6695369fe9be209552f953456eeac0aedbe83f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wpdatabase2-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for wpdatabase2-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 86e71590cb7ec86626dfc596a1245500b98407958cd6a804046493d4248c0d6c
MD5 b0a3a12ff0548fb2d0268dbe0b56927d
BLAKE2b-256 9c131e086f882864b2a996bca7973460b0cd6d6ea75b2327b2df34106dd73af9

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