https://github.com/aiidateam/pgsu

Connect to an existing PostgreSQL cluster as the `postgres` superuser and execute SQL commands.

https://github.com/aiidateam/pgsu

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 6 committers (16.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.4%) to scientific vocabulary

Keywords from Contributors

rabbitmq
Last synced: 11 months ago · JSON representation

Repository

Connect to an existing PostgreSQL cluster as the `postgres` superuser and execute SQL commands.

Basic Info
  • Host: GitHub
  • Owner: aiidateam
  • License: mit
  • Language: Python
  • Default Branch: master
  • Size: 74.2 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • Open Issues: 3
  • Releases: 5
Created over 7 years ago · Last pushed about 2 years ago
Metadata Files
Readme License

README.md

Build Status Coverage Status PyPI version GitHub license

pgsu

Connect to an existing PostgreSQL cluster as a PostgreSQL SUPERUSER and execute SQL commands.

psycopg has a great API for interacting with PostgreSQL, once you provide it with the connection parameters for a given database. However, what if your desired database and database user do not yet exist? In order to create them, you will need to connect to PostgreSQL as a SUPERUSER.

Features

  • autodetects postgres setup, tested on
  • uses psycopg to connect if possible
  • can use sudo to become the postgres UNIX user if necessary/possible (default Ubuntu PostgreSQL setups)

Usage

Python API

python from pgsu import PGSU pgsu = PGSU() # On Ubuntu, this may prompt for sudo password pgsu.execute("CREATE USER newuser WITH PASSWORD 'newpassword'") users = pgsu.execute("SELECT usename FROM pg_user WHERE usename='newuser'") print(users)

While the main point of the package is to guess how to connect as a postgres superuser, you can also provide partial or all information abut the setup using the dsn parameter. These are the default settings: python from pgsu import PGSU pgsu = PGSU(dsn={ 'host': None, 'port': 5432, 'user': 'postgres', 'password': None, 'dbname': 'template1', # Note: you cannot drop databases you are connected to })

Command line tool

The package also comes with a very basic pgsu command line tool that allows users to execute PostgreSQL commands as the superuser: $ pgsu "SELECT usename FROM pg_user" Trying to connect to PostgreSQL... Executing query: SELECT usename FROM pg_user [('aiida_qs_leopold',), ('postgres',)]

Tests

Run the tests as follows: bash pip install -e .[dev] pytest

Owner

  • Name: AiiDA team
  • Login: aiidateam
  • Kind: organization

The development team of AiiDA

GitHub Events

Total
  • Issue comment event: 2
  • Pull request review event: 3
  • Pull request review comment event: 4
  • Pull request event: 2
  • Fork event: 1
Last Year
  • Issue comment event: 2
  • Pull request review event: 3
  • Pull request review comment event: 4
  • Pull request event: 2
  • Fork event: 1

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 51
  • Total Committers: 6
  • Avg Commits per committer: 8.5
  • Development Distribution Score (DDS): 0.314
Past Year
  • Commits: 9
  • Committers: 1
  • Avg Commits per committer: 9.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Leopold Talirz l****z@g****m 35
Sebastiaan Huber m****l@s****t 9
Chris Sewell c****l@h****m 2
Daniel Hollas d****s@b****k 2
Leopold Talirz a****z@m****m 2
Joseph Weston j****h@w****d 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 12
  • Total pull requests: 30
  • Average time to close issues: 5 months
  • Average time to close pull requests: 15 days
  • Total issue authors: 4
  • Total pull request authors: 5
  • Average comments per issue: 1.75
  • Average comments per pull request: 1.43
  • Merged pull requests: 27
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ltalirz (8)
  • danielhollas (2)
  • jbweston (1)
  • zhubonan (1)
Pull Request Authors
  • ltalirz (21)
  • sphuber (10)
  • danielhollas (3)
  • jbweston (1)
  • chrisjsewell (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/ci.yml actions
  • CasperWA/postgresql-action v1.2 composite
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
  • codecov/codecov-action v1 composite
  • conda-incubator/setup-miniconda v2 composite
  • postgres 10.8 docker
.github/workflows/publish-on-pypi.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
  • pypa/gh-action-pypi-publish master composite
pyproject.toml pypi
setup.py pypi