HitchBuildPg
A small, self contained python library for building postgres database locally that, on first run will:
-
Downloads and compiles a specified version of postgres.
-
Builds a database from a series of SQL commands and by restoring a database dump file.
-
Takes a snapshot of the newly built database files by taking a copy of the folder.
On subsequent builds, it will skip the long, expensive steps of downloading, compiling postgres and restoring a database from a .sql file and just overwrite the data files.
import hitchbuildpg
postgres_version = "10.10"
pgapp_dir = "{}/postgres-{}".format(share, postgres_version)
pgapp = hitchbuildpg.PostgresApp(pgapp_dir, postgres_version)
class DataBuild(hitchbuildpg.DataBuild):
def run(self):
self.run_sql_as_root("create user myuser with password 'mypassword';")
self.run_sql_as_root("create database mydb with owner myuser;")
self.load_database_dump(
database="mydb",
username="myuser",
password="mypassword",
filename="dump.sql"
)
pgdata = hitchbuildpg.PostgresDatafiles(
"./myappdata",
pgapp,
DataBuild(),
)
pgdata.ensure_built()
db_service = pgdata.server()
db_service.start()
psql = db_service.psql(
"-U", "myuser", "-p", "15432", "-d", "mydb",
).with_env(PG_PASSWORD="mypassword")
psql("-c", "select name from cities where location = 'GB';").run()
# Prints output of SQL statement
psql("-c", "delete from cities where location = 'GB';").run()
db_service.stop()
Metadata
Release files for hitchbuildpg 0.4.1
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 | Actions |
|---|---|---|---|---|
| hitchbuildpg-0.4.1.tar.gz | 4.7 kB | Without provenance | Details for hitchbuildpg-0.4.1.tar.gz |
Release files / hitchbuildpg-0.4.1.tar.gz
| Download URL | hitchbuildpg-0.4.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
039239aaa51c7303e9dc0245020695f2a7ace341b1bfdf95023d5f525225d309
|
|
BLAKE2b-256 checksum How to use checksums |
a320063f290b4d84091aae5ede0bdf9aa502bcb299a4e3869422e2cf9f40799a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2
|
Security for hitchbuildpg 0.4.1
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.