postgresql-integration-test
Overview
postgresql-integration-test is a python module that creates a temporary PostgreSQL instance to use for testing your application. You will need a working PostgreSQL install. It does not have to be running, the binaries are needed.
Download and Install
To install use pip:
$ pip install postgresql-integration-test
Or clone the repo:
$ git clone https://github.com/jasondcamp/postgresql-integration-test.git
Configuration
Class arguments
The following class arguments can be overridden by passing them in, these arguments will override the config file arguments.
| Argument | Description | Default |
|---|---|---|
| username | Username for database | root |
| host | Host to bind | 127.0.0.1 |
| port | Port to bind | random |
| postgres_binary | Location of postgres binary | Searches paths |
| timeout_start | Timeout to start PostgreSQL | 30 seconds |
| timeout_stop | Timeout to stop PostgreSQL | 30 seconds |
| log_level | Log level | INFO |
| config_file | Configuration file | postgresql-integration-test.cfg |
postgresql-integration-test config file
Default settings can be overridden in a config file. The default name is postgresql-integration-test.cfg in the local directory and can be overridden by passing in the config option to the instance creation.
Example config
database:
host: '127.0.0.1'
port: '9999'
username: 'root'
postgresql_binary: '/usr/sbin/postgres'
general:
log_level: 'DEBUG'
timeout_start: 30
timeout_stop: 30
Usage
import
from postgresql_integration_test import PostgreSQL
run
Starts up the postgresql server
postgresql = PostgreSQL()
instance = postgresql.run()
stop
Stops the postgres server
postgresql.stop()
Example Code
#!/usr/bin/env python3
from postgresql_integration_test import PostgreSQL
import psycopg2
postgres = PostgreSQL(config='/some/dir/postgresql-integration-test.cfg')
instance = postgres.run()
# Make query to database
cnx = psycopg2.connect(
user=instance.username,
host=instance.host,
port=instance.port,
database="test",
)
cursor = cnx.cursor()
cursor.execute("SELECT id FROM some_table")
for _result in cursor:
result = _result
cursor.close()
cnx.close()
postgres.stop()
Metadata
Release files for postgresql-integration-test 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| postgresql_integration_test-0.0.7.tar.gz | 14.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| postgresql_integration_test-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.7 kB
Release files / postgresql_integration_test-0.0.7.tar.gz
| Download URL | postgresql_integration_test-0.0.7.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22b8e85a4741efb10429e2d7f9efb0c98582a68cc101f5bba60d050ba02dfa18
|
|
BLAKE2b-256 checksum How to use checksums |
ec4c4859f535a5a442248dc2543afe10bccdc0ad971c3b90b0db43f785dfbf4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / postgresql_integration_test-0.0.7-py3-none-any.whl
| Download URL | postgresql_integration_test-0.0.7-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1eb0bbd89e5b2a0c2f23289e2e5e5a02c902407026f47ce6063600e249bc0226
|
|
BLAKE2b-256 checksum How to use checksums |
faff273b7e30abb02b0b24178c80604959fe97baf9facde3f73e6d786174a077
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for postgresql-integration-test 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.