PostgreSQL database adapter for the Python programming language

Overview

psycopg2 - Python-PostgreSQL Database Adapter

Psycopg is the most popular PostgreSQL database adapter for the Python programming language. Its main features are the complete implementation of the Python DB API 2.0 specification and the thread safety (several threads can share the same connection). It was designed for heavily multi-threaded applications that create and destroy lots of cursors and make a large number of concurrent "INSERT"s or "UPDATE"s.

Psycopg 2 is mostly implemented in C as a libpq wrapper, resulting in being both efficient and secure. It features client-side and server-side cursors, asynchronous communication and notifications, "COPY TO/COPY FROM" support. Many Python types are supported out-of-the-box and adapted to matching PostgreSQL data types; adaptation can be extended and customized thanks to a flexible objects adaptation system.

Psycopg 2 is both Unicode and Python 3 friendly.

Documentation

Documentation is included in the doc directory and is available online.

For any other resource (source code repository, bug tracker, mailing list) please check the project homepage.

Installation

Building Psycopg requires a few prerequisites (a C compiler, some development packages): please check the install and the faq documents in the doc dir or online for the details.

If prerequisites are met, you can install psycopg like any other Python package, using pip to download it from PyPI:

$ pip install psycopg2

or using setup.py if you have downloaded the source package locally:

$ python setup.py build
$ sudo python setup.py install

You can also obtain a stand-alone package, not requiring a compiler or external libraries, by installing the psycopg2-binary package from PyPI:

$ pip install psycopg2-binary

The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources.

Linux/OSX: Linux and OSX build status
Windows: Windows build status
Comments
  • (Django)(MAC Big Sur 11.0.1) ImportError: dlopen

    (Django)(MAC Big Sur 11.0.1) ImportError: dlopen

    Apologies in advance -- this is probably doubling up on #1200 and #1208, but I'm curious as to whether there's any workaround whatsoever (as I really would like to use postgresql with my project, but I'm too much of a newb to comprehend most of the issues I run into). I've tried pretty much every suggestion to be found through googling to no avail. The issue is as below:

    • Mac Big Sur (OS 11.0.1)
    • Python 3.9 (venv)

    Installed pyscopg2 to the venv without any issues using: pip install psycopg2

    Meanwhile, Postgresql was successfully installed and the db I'd like to connect to is active (using pgadmin4). Django settings are configured accordingly.

    However, when trying to access psycopg2 through the terminal, whether it be through: python -c "import psycopg2" or python manage.py migrate, etc.

    The below error occurs: (venv) ...-MacBook-Air project % python -c "import psycopg2" Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/.../Documents/project/venv/lib/python3.9/site-packages/psycopg2/__init__.py", line 51, in <module> from psycopg2._psycopg import ( # noqa ImportError: dlopen(/Users/.../Documents/project/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 2): no suitable image found. Did find: /Users/.../Documents/project/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so: mach-o, but wrong architecture /Users/.../Documents/project/venv/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so: mach-o, but wrong architecture

    Any help/insight would be greatly appreciated. Or are all of us who jumped ship to M1 doomed until Apple stop breaking things? :)

    opened by awildjosh 87
  • psycopg2-binary fails to install on macOS Big Sur 11.0.1 and Python 3.9.0 (with possible workaround)

    psycopg2-binary fails to install on macOS Big Sur 11.0.1 and Python 3.9.0 (with possible workaround)

    Environment:

    • macOS 11.0.1 (Big Sur)
    • Python 3.9.0 (installed via pyenv)

    When I attempt to pip-install psycopg2-binary with in a venv, the installer instead tries to compile psycopg2 and fails for me as I don't have PostgreSQL installed:

    $ pip install psycopg2-binary
    Collecting psycopg2-binary
      Using cached psycopg2-binary-2.8.6.tar.gz (384 kB)
        ERROR: Command errored out with exit status 1:
         command: /Users/amar/test3/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-install-jo9na1rs/psycopg2-binary/setup.py'"'"'; __file__='"'"'/private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-install-jo9na1rs/psycopg2-binary/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-pip-egg-info-mgvwjdyx
             cwd: /private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-install-jo9na1rs/psycopg2-binary/
        Complete output (23 lines):
        running egg_info
        creating /private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-pip-egg-info-mgvwjdyx/psycopg2_binary.egg-info
        writing /private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-pip-egg-info-mgvwjdyx/psycopg2_binary.egg-info/PKG-INFO
        writing dependency_links to /private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-pip-egg-info-mgvwjdyx/psycopg2_binary.egg-info/dependency_links.txt
        writing top-level names to /private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-pip-egg-info-mgvwjdyx/psycopg2_binary.egg-info/top_level.txt
        writing manifest file '/private/var/folders/73/97rprb4s6qz9qc7n8xy0vt800000gn/T/pip-pip-egg-info-mgvwjdyx/psycopg2_binary.egg-info/SOURCES.txt'
        
        Error: pg_config executable not found.
        
        pg_config is required to build psycopg2 from source.  Please add the directory
        containing pg_config to the $PATH or specify the full executable path with the
        option:
        
            python setup.py build_ext --pg-config /path/to/pg_config build ...
        
        or with the pg_config option in 'setup.cfg'.
        
        If you prefer to avoid building psycopg2 from source, please install the PyPI
        'psycopg2-binary' package instead.
        
        For further information please check the 'doc/src/install.rst' file (also at
        <https://www.psycopg.org/docs/install.html>).
    

    I can get around this using the SYSTEM_VERSION_COMPAT=1 env var. That sets the macOS version to 10.16 instead of 11.0:

    $ SYSTEM_VERSION_COMPAT=1 pip install psycopg2-binary
    Collecting psycopg2-binary
      Downloading psycopg2_binary-2.8.6-cp39-cp39-macosx_10_9_x86_64.macosx_10_9_intel.macosx_10_10_intel.macosx_10_10_x86_64.whl (1.5 MB)
         |████████████████████████████████| 1.5 MB 5.1 MB/s 
    Installing collected packages: psycopg2-binary
    Successfully installed psycopg2-binary-2.8.6
    

    Note, I haven't tested using this psycopg2-binary on Big Sur yet. I'm running into install issues with Pillow that I'm sorting out too. (How I wish I didn't upgrade to Big Sur yet!)

    opened by akurani 69
  • Add support for streaming replication protocol

    Add support for streaming replication protocol

    Introduce ReplicationConnection and ReplicationCursor classes, that incapsulate initiation of special type of PostgreSQL connection and handling of special replication commands only available in this special connection mode.

    The handling of stream of replication data from the server is modelled largely after the existing support for "COPY table TO file" command and pg_recvlogical tool supplied with PostgreSQL (though, it can also be used for physical replication.)

    opened by a1exsh 62
  • psycopg2-binary support for M1 chipset

    psycopg2-binary support for M1 chipset

    Hello all, With a big of guidance I'm happy to contribute a PR. For now, let me document the current situation for any other M1 users. Please do correct me if I got the details wrong!

    Python 3.8.10 is the first 3.8 version with support for M1 chipset (see bug). Older versions of pyenv do not have access to Python 3.8.10 (some details in here).

    pyenv install 3.8.10
    python -m venv .venv
    source .venv/bin/activate
    python -m pip install --upgrade pip wheel
    

    If you try to install psycopg2_binary and expect a wheel, it is not currently available.

    There's the SYSTEM_VERSION_COMPAT=1 trick to pretend to be 10.6 instead of 11.x, however, the architecture still returns arm64.

    ❯ python -c "import platform; print(platform.mac_ver())"
    ('11.4', ('', '', ''), 'arm64')
    
    ~/code/M1 via 🐍 v3.8.2 (venv_3_system) on ☁️  [email protected]
    ❯ SYSTEM_VERSION_COMPAT=1 python -c "import platform; print(platform.mac_ver())"
    ('10.16', ('', '', ''), 'arm64')
    

    If you don't have a wheel then you need to build from source. See the log [1] at the bottom of this comment.

    In order to have the libraries to build it, I took these steps which are based on this post:

    brew install postgresql
    # If you open a new terminal tab you will see that pg_config is available
    export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
    export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib -L${HOME}/.pyenv/versions/3.8.10/lib"
    

    After that, it is possible to build the wheel

    pip install psycopg2-binary==2.8.6
    Collecting psycopg2-binary==2.8.6
      Using cached psycopg2-binary-2.8.6.tar.gz (384 kB)
    Building wheels for collected packages: psycopg2-binary
      Building wheel for psycopg2-binary (setup.py) ... done
      Created wheel for psycopg2-binary: filename=psycopg2_binary-2.8.6-cp38-cp38-macosx_11_0_arm64.whl size=137096 sha256=af1103eb3c4d9fee1636d27e9dbab6c8bbe7fcd8502bea2a4a194f016a8afb85
      Stored in directory: /Users/armenzg/Library/Caches/pip/wheels/15/d7/13/ef37b82cf1de521c82c129a16ad8007a81b4eab0f23b22c7b3
    Successfully built psycopg2-binary
    Installing collected packages: psycopg2-binary
    Successfully installed psycopg2-binary-2.8.6
    

    Did I do this right? How can I help to have a release that includes an arm64 wheel?

    [1]

    SYSTEM_VERSION_COMPAT=1 pip install psycopg2-binary==2.8.6
    Collecting psycopg2-binary==2.8.6
      Using cached psycopg2-binary-2.8.6.tar.gz (384 kB)
        ERROR: Command errored out with exit status 1:
         command: /Users/armenzg/code/M1/venv_3_system/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-install-9zonoxgp/psycopg2-binary_43fe9c32f13f470ebebbbdf290cabfe4/setup.py'"'"'; __file__='"'"'/private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-install-9zonoxgp/psycopg2-binary_43fe9c32f13f470ebebbbdf290cabfe4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-pip-egg-info-cacpi1hg
             cwd: /private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-install-9zonoxgp/psycopg2-binary_43fe9c32f13f470ebebbbdf290cabfe4/
        Complete output (23 lines):
        running egg_info
        creating /private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-pip-egg-info-cacpi1hg/psycopg2_binary.egg-info
        writing /private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-pip-egg-info-cacpi1hg/psycopg2_binary.egg-info/PKG-INFO
        writing dependency_links to /private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-pip-egg-info-cacpi1hg/psycopg2_binary.egg-info/dependency_links.txt
        writing top-level names to /private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-pip-egg-info-cacpi1hg/psycopg2_binary.egg-info/top_level.txt
        writing manifest file '/private/var/folders/j1/d109sd4n55qbk5ty8gzq5jgm0000gn/T/pip-pip-egg-info-cacpi1hg/psycopg2_binary.egg-info/SOURCES.txt'
    
        Error: pg_config executable not found.
    
        pg_config is required to build psycopg2 from source.  Please add the directory
        containing pg_config to the $PATH or specify the full executable path with the
        option:
    
            python setup.py build_ext --pg-config /path/to/pg_config build ...
    
        or with the pg_config option in 'setup.cfg'.
    
        If you prefer to avoid building psycopg2 from source, please install the PyPI
        'psycopg2-binary' package instead.
    
        For further information please check the 'doc/src/install.rst' file (also at
        <https://www.psycopg.org/docs/install.html>).
    
        ----------------------------------------
    WARNING: Discarding https://files.pythonhosted.org/packages/fc/51/0f2c6aec5c59e5640f507b59567f63b9d73a9317898810b4db311da32dfc/psycopg2-binary-2.8.6.tar.gz#sha256=11b9c0ebce097180129e422379b824ae21c8f2a6596b159c7659e2e5a00e1aa0 (from https://pypi.org/simple/psycopg2-binary/) (requires-python:>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    ERROR: Could not find a version that satisfies the requirement psycopg2-binary==2.8.6 (from versions: 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6)
    ERROR: No matching distribution found for psycopg2-binary==2.8.6
    
    opened by armenzg 39
  • Empty OperationalError on connect

    Empty OperationalError on connect

    Hello,

    I have noticed it is possible to optain an empty OperationalError while connecting to a PostgreSQL database. There is no information attached to this error, both pgerror and pgcode remain empty.

    While beeing unsuccessful debugging this issue on client site with this error message looking to the server side reveals a log entry for "password incorrect". As far as I can see in your code there should be an error code explicit for this situation.

    Using python 3.5 and PostgreSQL 9.3.

    Thanks in advnace and best regards

    Nerade

    windows 
    opened by Nerade 39
  • Segmentation fault when connecting using SSL

    Segmentation fault when connecting using SSL

    tl;dr

    This segfault only affects the psycopg wheel package: the workaround is to build psycopg from source, e.g. using:

    $ pip install --no-binary psycopg2
    

    or the entry in the requirements.txt file:

    psycopg2>=2.7,<2.8 --no-binary psycopg2
    

    Running the delete_database function in this snippet against our database causes a segmentation fault in psycopg2==2.7 and 2.7.1, but not in 2.6.2. The segmentation fault seems to happen inside OpenSSL. Debugging revealed that SSL_library_init is being called twice, once by the Python ssl module and once by the libpq library that comes with psycopg2, where it segfaults. Not sure if this function is allowed to be called twice or not.

    import contextlib
    
    import psycopg2
    
    from fabfile.lib import info, parse_uri
    
    
    @contextlib.contextmanager
    def create_connection(connection_uri):
        connection_args = parse_uri(connection_uri)
        conn = psycopg2.connect(
            database='postgres', user=connection_args.username,
            password=connection_args.password, host=connection_args.hostname,
            port=connection_args.port if connection_args.port else 5432)
        conn.set_isolation_level(0)
        yield conn.cursor()
        conn.close()
    
    def delete_database(connection_uri, database):
        hostname = parse_uri(connection_uri).hostname
        info('deleting database {} on {}'.format(database, hostname))
        with create_connection(connection_uri) as cur:
            cur.execute('''SELECT pg_terminate_backend(pg_stat_activity.pid)
                           FROM pg_stat_activity
                           WHERE pg_stat_activity.datname = %s
                             AND pid <> pg_backend_pid()''', (database, ))
            cur.execute('DROP DATABASE "{}"'.format(database))
    
    

    The system openssl is 1.0.1f-1ubuntu2.22 on Ubuntu 14.04.

    On psycopg2==2.6.2 this works fine.

    On psycopg2==2.7 we get the following segmentation fault:

    Program received signal SIGSEGV, Segmentation fault.
    engine_unlocked_finish (e=e@entry=0x7ffff626bfa0 <update>, unlock_for_handlers=unlock_for_handlers@entry=1) at eng_init.c:92
    92	eng_init.c: No such file or directory.
    (gdb) bt
    #0  engine_unlocked_finish (e=e@entry=0x7ffff626bfa0 <update>, unlock_for_handlers=unlock_for_handlers@entry=1) at eng_init.c:92
    #1  0x00007ffff6251d69 in ENGINE_finish (e=0x7ffff626bfa0 <update>) at eng_init.c:146
    #2  0x00007ffff6264f05 in EVP_DigestInit_ex (ctx=0x10cb600, type=0x7ffff6540080 <sha1_md>, impl=0x0) at digest.c:162
    #3  0x00007ffff28fe8a4 in ssl23_connect () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/./libssl-a65b360f.so.0.9.8e
    #4  0x00007ffff2b63a9c in ?? () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-cf361c55.so.5.8
    #5  0x00007ffff2b63fbd in ?? () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-cf361c55.so.5.8
    #6  0x00007ffff2b5175e in PQconnectPoll () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-cf361c55.so.5.8
    #7  0x00007ffff2b520ce in ?? () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-cf361c55.so.5.8
    #8  0x00007ffff2b529bf in PQconnectdb () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-cf361c55.so.5.8
    #9  0x00007ffff2d8c241 in _conn_sync_connect (self=0x7ffff2ff8c80) at psycopg/connection_int.c:716
    #10 conn_connect (self=self@entry=0x7ffff2ff8c80, async=<optimized out>) at psycopg/connection_int.c:812
    #11 0x00007ffff2d8cf84 in connection_setup (async=<optimized out>, dsn=<optimized out>, self=0x7ffff2ff8c80) at psycopg/connection_type.c:1277
    #12 connection_init (obj=obj@entry=<psycopg2.extensions.connection at remote 0x7ffff2ff8c80>, args=args@entry=('dbname=postgres host=**censored ip** user=admin password=**censored password** port=5432',), kwds=kwds@entry=0x0)
        at psycopg/connection_type.c:1362
    #13 0x000000000055f6db in type_call.25495 (type=<optimized out>, type@entry=0x7ffff2fab460 <connectionType>, args=args@entry=('dbname=postgres host=**censored ip** user=admin password=**censored password** port=5432',), kwds=kwds@entry=0x0)
        at ../Objects/typeobject.c:745
    #14 0x00000000004c8a7d in PyObject_Call (kw=0x0, arg=('dbname=postgres host=**censored ip** user=admin password=**censored password** port=5432',), func=<type at remote 0x7ffff2fab460>) at ../Objects/abstract.c:2529
    #15 call_function_tail.5417 (callable=callable@entry=<type at remote 0x7ffff2fab460>, args=('dbname=postgres host=**censored ip** user=admin password=**censored password** port=5432',)) at ../Objects/abstract.c:2561
    #16 0x00000000005ab155 in _PyObject_CallFunction_SizeT (callable=<type at remote 0x7ffff2fab460>, format=format@entry=0x7ffff2da3f60 "s") at ../Objects/abstract.c:2605
    #17 0x00007ffff2d860b8 in psyco_connect (self=<optimized out>, args=<optimized out>, keywds=<optimized out>) at psycopg/psycopgmodule.c:111
    #18 0x000000000052714b in ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffc340, func=<built-in function _connect>) at ../Python/ceval.c:4330
    #19 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff3071850, for file /usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py, line 130, in connect (dsn='dbname=postgres host=**censored ip** user=admin password=**censored password** port=5432', connection_factory=None, cursor_factory=None, kwargs={'port': 5432, 'host': '**censored ip**', 'password': '**censored password**', 'user': 'admin', 'database': 'postgres'}, kwasync={}), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #20 0x0000000000555551 in PyEval_EvalCodeEx (co=0x7ffff3047130, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=argcount@entry=0, kws=<optimized out>, kwcount=kwcount@entry=5,
        defs=defs@entry=0x7ffff305b838, defcount=3, closure=0x0) at ../Python/ceval.c:3252
    #21 0x0000000000524338 in fast_function (nk=5, na=0, n=<optimized out>, pp_stack=0x7fffffffc530, func=<function at remote 0x7ffff3061050>) at ../Python/ceval.c:4116
    #22 call_function (oparg=<optimized out>, pp_stack=0x7fffffffc530) at ../Python/ceval.c:4041
    #23 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xf37790, for file /home/ubuntu/workspace/external-database-create/awingu/clouddesktop-reposerver/fabfile/external_database/postgresql.py, line 21, in create_connection (connection_uri='postgresql://admin:**censored password**@**censored ip**:5432/', connection_args=<ParseResult(database='') at remote 0x7ffff3061938>), throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #24 0x0000000000567b1e in gen_send_ex.isra.0 (exc=0, arg=0x0) at ../Objects/genobject.c:85
    #25 gen_iternext (gen=0x7ffff30626e0, gen@entry=<error reading variable: value has been optimized out>) at ../Objects/genobject.c:283
    #26 0x00000000004c96a9 in wrap_next.25272 (self=<optimized out>, args=<optimized out>, wrapped=<optimized out>) at ../Objects/typeobject.c:4683
    #27 0x00000000005244dd in PyObject_Call (kw=0x0, arg=(), func=<method-wrapper at remote 0x7ffff3050ad0>) at ../Objects/abstract.c:2529
    #28 do_call (nk=<optimized out>, na=<optimized out>, pp_stack=0x7fffffffc6b0, func=<method-wrapper at remote 0x7ffff3050ad0>) at ../Python/ceval.c:4238
    #29 call_function (oparg=<optimized out>, pp_stack=0x7fffffffc6b0) at ../Python/ceval.c:4043
    #30 PyEval_EvalFrameEx (f=f@entry=Frame 0x7ffff2fbf5c0, for file /usr/lib/python2.7/contextlib.py, line 17, in __enter__ (self=<GeneratorContextManager(gen=<generator at remote 0x7ffff30626e0>) at remote 0x7ffff304a790>),
        throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #31 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-218368576, args=<optimized out>, locals=0x0, globals=<optimized out>,
        co=<optimized out>) at ../Python/ceval.c:3252
    #32 function_call (func=func@entry=<function at remote 0x7ffff6af2c80>, arg=arg@entry=(<GeneratorContextManager(gen=<generator at remote 0x7ffff30626e0>) at remote 0x7ffff304a790>,), kw=kw@entry=0x0) at ../Objects/funcobject.c:526
    #33 0x00000000004c2604 in PyObject_Call (kw=0x0, arg=(<GeneratorContextManager(gen=<generator at remote 0x7ffff30626e0>) at remote 0x7ffff304a790>,), func=<function at remote 0x7ffff6af2c80>) at ../Objects/abstract.c:2529
    #34 instancemethod_call.8802 (func=<function at remote 0x7ffff6af2c80>, arg=(<GeneratorContextManager(gen=<generator at remote 0x7ffff30626e0>) at remote 0x7ffff304a790>,), kw=0x0) at ../Objects/classobject.c:2602
    #35 0x00000000004c6e74 in PyObject_Call (kw=0x0, arg=(), func=<instancemethod at remote 0x7ffff4812aa0>) at ../Objects/abstract.c:2529
    #36 PyObject_CallFunctionObjArgs (callable=callable@entry=<instancemethod at remote 0x7ffff4812aa0>) at ../Objects/abstract.c:2760
    #37 0x0000000000526020 in PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff305d638, for file /home/ubuntu/workspace/external-database-create/awingu/clouddesktop-reposerver/fabfile/external_database/postgresql.py, line 53, in delete_database (connection_uri='postgresql://admin:**censored password**@**censored ip**:5432/', database='nghtdef_frontend', hostname='**censored ip**'), throwflag=throwflag@entry=0) at ../Python/ceval.c:2555
    #38 0x00000000005247ea in fast_function (nk=<optimized out>, na=<optimized out>, n=2, pp_stack=0x7fffffffcd30, func=<function at remote 0x7ffff30617d0>) at ../Python/ceval.c:4106
    ---Type <return> to continue, or q <return> to quit---[
    #39 call_function (oparg=<optimized out>, pp_stack=0x7fffffffcd30) at ../Python/ceval.c:4041
    #40 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xdac250, for file /home/ubuntu/workspace/external-database-create/awingu/clouddesktop-reposerver/fabfile/external_database/__init__.py, line 159, in delete (config={u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, connection_uri='postgresql://admin:**censored password**@**censored ip**:5432/', database_uris=('postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), connection_args=<ParseResult(database='') at remote 0x7ffff30f3e60>, scheme=u'postgresql', delete_user=<function at remote 0x7ffff3061758>, delete_database=<function at remote 0x7ffff30617d0>, exceptions=[], database_uri='postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', db_args=<ParseResult(database='nghtdef_frontend') at remote 0x7ffff3061848>), throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #41 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=14336592, args=<optimized out>, locals=0x0, globals=<optimized out>,
        co=<optimized out>) at ../Python/ceval.c:3252
    #42 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    
    #43 0x0000000000525cb7 in PyObject_Call (kw={},
        arg=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), func=<function at remote 0x7ffff30f3c80>) at ../Objects/abstract.c:2529
    #44 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffcf30, func=<function at remote 0x7ffff30f3c80>) at ../Python/ceval.c:4333
    #45 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff2fbf960, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 173, in run (self=<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff30f3c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff2fb9b90>, args=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_fronte...(truncated), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #46 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-218367648, args=<optimized out>, locals=0x0, globals=<optimized out>,
        co=<optimized out>) at ../Python/ceval.c:3252
    #47 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #48 0x0000000000525cb7 in PyObject_Call (kw={},
        arg=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff30f3c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff2fb9b90>, {u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**...(truncated), func=<function at remote 0x7ffff50f4aa0>) at ../Objects/abstract.c:2529
    #49 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffd130, func=<function at remote 0x7ffff50f4aa0>) at ../Python/ceval.c:4333
    
    #50 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff2fbf790, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 170, in __call__ (self=<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff30f3c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff2fb9b90>, args=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_f...(truncated), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #51 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-218368112, args=<optimized out>, locals=0x0, globals=<optimized out>,
        co=<optimized out>) at ../Python/ceval.c:3252
    #52 function_call (func=func@entry=<function at remote 0x7ffff50f4a28>,
        arg=arg@entry=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff30f3c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff2fb9b90>, {u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**...(truncated), kw=kw@entry=0x0) at ../Objects/funcobject.c:526
    #53 0x00000000004c2604 in PyObject_Call (kw=0x0,
        arg=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff30f3c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff2fb9b90>, {u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**...(truncated), func=<function at remote 0x7ffff50f4a28>) at ../Objects/abstract.c:2529
    ---Type <return> to continue, or q <return> to quit---
    #54 instancemethod_call.8802 (func=<function at remote 0x7ffff50f4a28>, func@entry=<instancemethod at remote 0x7ffff4856140>,
        arg=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff30f3c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff2fb9b90>, {u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**...(truncated),
        arg@entry=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), kw=kw@entry=0x0) at ../Objects/classobject.c:2602
    #55 0x00000000004d26cf in PyObject_Call (kw=0x0,
        arg=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), func=<instancemethod at remote 0x7ffff4856140>)
        at ../Objects/abstract.c:2529
    #56 slot_tp_call.25849 (self=<optimized out>,
        args=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), kwds=0x0) at ../Objects/typeobject.c:5432
    #57 0x0000000000525cb7 in PyObject_Call (kw=0x0,
        arg=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'),
        func=<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff30f3c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff2fb9b90>) at ../Objects/abstract.c:2529
    #58 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffd650,
        func=<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff30f3c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff2fb9b90>) at ../Python/ceval.c:4333
    #59 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff311ada8, for file /home/ubuntu/workspace/external-database-create/awingu/clouddesktop-reposerver/fabfile/external_database/__init__.py, line 74, in delete_all (config_name='postgresql', prefix='nghtdef', config={u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, connection_uri='postgresql://admin:**censored password**@**censored ip**:5432/', databases={'frontend_web': 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'graphite_web': 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'}),
        throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #60 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-216945240, args=<optimized out>, locals=0x0, globals=<optimized out>,
        co=<optimized out>) at ../Python/ceval.c:3252
    #61 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #62 0x0000000000525cb7 in PyObject_Call (kw={}, arg=('postgresql', 'nghtdef'), func=<function at remote 0x7ffff30f3b90>) at ../Objects/abstract.c:2529
    #63 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffd850, func=<function at remote 0x7ffff30f3b90>) at ../Python/ceval.c:4333
    #64 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff2fbf3f0, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 173, in run (self=<WrappedCallableTask(__module__='fabfile.external_database', name='delete_all', is_default=False, wrapped=<function at remote 0x7ffff30f3b90>, __name__='delete_all', __doc__=None) at remote 0x7ffff30eec10>, args=('postgresql', 'nghtdef'), kwargs={}), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #65 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-218369040, args=<optimized out>, locals=0x0, globals=<optimized out>,
        co=<optimized out>) at ../Python/ceval.c:3252
    #66 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #67 0x0000000000525cb7 in PyObject_Call (kw={},
        arg=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete_all', is_default=False, wrapped=<function at remote 0x7ffff30f3b90>, __name__='delete_all', __doc__=None) at remote 0x7ffff30eec10>, 'postgresql', 'nghtdef'), func=<function at remote 0x7ffff50f4aa0>) at ../Objects/abstract.c:2529
    #68 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffda50, func=<function at remote 0x7ffff50f4aa0>) at ../Python/ceval.c:4333
    #69 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xf2a6f0, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 276, in _execute (task=<WrappedCallableTask(__module__='fabfile.external_database', name='delete_all', is_default=False, wrapped=<function at remote 0x7ffff30f3b90>, __name__='delete_all', __doc__=None) at remote 0x7ffff30eec10>, host='localhost', my_env={'clean_revert': True, 'all_hosts': ['localhost'], 'effective_roles': [], 'command': 'external_database.delete_all'}, args=('postgresql', 'nghtdef'), kwargs={}, jobs=<JobQueue(_finished=False, _queued=[], _running=[], _debug=False, _num_of_jobs=0, _closed=False, _max=1, _comms_queue=None, _completed=[]) at remote 0x7ffff2fb9d10>, queue=None, multiprocessing=None, local_env={'effective_roles': [...], 'all_hosts': [...], 'port': '22', 'clean_revert': True, 'host': 'localhost', 'command': 'external_database.delete_all', 'user': 'root', 'host_string': 'localhost'}),
    ---Type <return> to continue, or q <return> to quit---
        throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #70 0x0000000000555551 in PyEval_EvalCodeEx (co=0x7ffff50bdf30, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=argcount@entry=8, kws=<optimized out>, kwcount=kwcount@entry=0, defs=defs@entry=0x0,
        defcount=defcount@entry=0, closure=0x0) at ../Python/ceval.c:3252
    #71 0x0000000000525560 in fast_function (nk=0, na=8, n=<optimized out>, pp_stack=0x7fffffffdc40, func=<function at remote 0x7ffff50f4cf8>) at ../Python/ceval.c:4116
    #72 call_function (oparg=<optimized out>, pp_stack=0x7fffffffdc40) at ../Python/ceval.c:4041
    #73 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xdabd50, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 386, in execute (task=<WrappedCallableTask(__module__='fabfile.external_database', name='delete_all', is_default=False, wrapped=<function at remote 0x7ffff30f3b90>, __name__='delete_all', __doc__=None) at remote 0x7ffff30eec10>, args=('postgresql', 'nghtdef'), kwargs={'hosts': [], 'roles': [], 'exclude_hosts': []}, my_env={'clean_revert': True, 'all_hosts': ['localhost'], 'effective_roles': [], 'command': 'external_database.delete_all'}, results={}, is_callable=False, new_kwargs={}, hosts=[...], roles=[...], exclude_hosts=[...], parallel=False, multiprocessing=None, pool_size=1, queue=None, jobs=<JobQueue(_finished=False, _queued=[], _running=[], _debug=False, _num_of_jobs=0, _closed=False, _max=1, _comms_queue=None, _completed=[]) at remote 0x7ffff2fb9d10>, host='localhost'), throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #74 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=14335312, args=<optimized out>, locals=0x0, globals=<optimized out>,
        co=<optimized out>) at ../Python/ceval.c:3252
    #75 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #76 0x0000000000525cb7 in PyObject_Call (kw={'hosts': [], 'roles': [], 'exclude_hosts': []}, arg=('external_database.delete_all', 'postgresql', 'nghtdef'), func=<function at remote 0x7ffff50f4de8>) at ../Objects/abstract.c:2529
    #77 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffde40, func=<function at remote 0x7ffff50f4de8>) at ../Python/ceval.c:4333
    #78 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xa138b0, for file /usr/local/lib/python2.7/dist-packages/fabric/main.py, line 756, in main (fabfile_locations=None, parser=<OptionParser(process_default_values=True, allow_interspersed_args=True, _long_opt={'--eagerly-disconnect': <Option(_long_opts=['--eagerly-disconnect'], help='disconnect from hosts as soon as possible', callback_args=None, callback=None, default=False, nargs=None, choices=None, dest='eagerly_disconnect', container=<...>, _short_opts=['-e'], action='store_true', const=None, callback_kwargs=None, type=None, metavar=None) at remote 0x7ffff533e3b0>, '--port': <Option(_long_opts=['--port'], help='SSH connection port', callback_args=None, callback=None, default='22', nargs=1, choices=None, dest='port', container=<...>, _short_opts=[], action='store', const=None, callback_kwargs=None, type='string', metavar=None) at remote 0x7ffff50cd950>, '--keepalive': <Option(_long_opts=['--keepalive'], help='enables a keepalive every N seconds', callback_args=None, callback=None, default=0, nargs=1, c...(truncated), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #79 0x0000000000555551 in PyEval_EvalCodeEx (co=0x7ffff7e9eab0, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=argcount@entry=0, kws=<optimized out>, kwcount=kwcount@entry=0,
        defs=defs@entry=0x7ffff4e81968, defcount=1, closure=0x0) at ../Python/ceval.c:3252
    #80 0x0000000000524338 in fast_function (nk=0, na=0, n=<optimized out>, pp_stack=0x7fffffffe030, func=<function at remote 0x7ffff4e89aa0>) at ../Python/ceval.c:4116
    #81 call_function (oparg=<optimized out>, pp_stack=0x7fffffffe030) at ../Python/ceval.c:4041
    #82 PyEval_EvalFrameEx (f=f@entry=Frame 0x7ffff7e713e0, for file /usr/local/bin/fab, line 11, in <module> (), throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #83 0x0000000000567d14 in PyEval_EvalCodeEx (closure=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=< at remote 0x7ffff7e71558>,
        globals='Return true if the object is a user-defined function.\n\n    Function objects provide these attributes:\n        __doc__         documentation string\n        __name__        name with which this function was defined\n        func_code       code object containing compiled function bytecode\n        func_defaults   tuple of any default values for arguments\n        func_doc        (same as __doc__)\n        func_globals    global namespace in which this function was defined\n        func_name       (same as __name__)', co=0x7ffff7edb1b0) at ../Python/ceval.c:3252
    #84 PyEval_EvalCode (locals=< at remote 0x7ffff7e71558>,
        globals='Return true if the object is a user-defined function.\n\n    Function objects provide these attributes:\n        __doc__         documentation string\n        __name__        name with which this function was defined\n        func_code       code object containing compiled function bytecode\n        func_defaults   tuple of any default values for arguments\n        func_doc        (same as __doc__)\n        func_globals    global namespace in which this function was defined\n        func_name       (same as __name__)', co=0x7ffff7edb1b0) at ../Python/ceval.c:667
    #85 run_mod.42576 (mod=mod@entry=0x977f18, filename=filename@entry=0x7fffffffe66b "/usr/local/bin/fab",
        globals=globals@entry={'__builtins__': <module at remote 0x7ffff7fa1b08>, '__file__': '/usr/local/bin/fab', '__package__': None, 'sys': <module at remote 0x7ffff7fa1bb0>, 're': <module at remote 0x7ffff7ed32b8>, '__name__': '__main__', 'main': <function at remote 0x7ffff4e89aa0>, '__doc__': None},
        locals=locals@entry={'__builtins__': <module at remote 0x7ffff7fa1b08>, '__file__': '/usr/local/bin/fab', '__package__': None, 'sys': <module at remote 0x7ffff7fa1bb0>, 're': <module at remote 0x7ffff7ed32b8>, '__name__': '__main__', 'main': <function at remote 0x7ffff4e89aa0>, '__doc__': None}, flags=flags@entry=0x7fffffffe1e0, arena=arena@entry=0x9a4a80) at ../Python/pythonrun.c:1370
    #86 0x0000000000465bf4 in PyRun_FileExFlags (fp=fp@entry=0x9ef390, filename=filename@entry=0x7fffffffe66b "/usr/local/bin/fab", start=start@entry=257,
        globals=globals@entry={'__builtins__': <module at remote 0x7ffff7fa1b08>, '__file__': '/usr/local/bin/fab', '__package__': None, 'sys': <module at remote 0x7ffff7fa1bb0>, 're': <module at remote 0x7ffff7ed32b8>, '__name__': '__main__', 'main': <function at remote 0x7ffff4e89aa0>, '__doc__': None},
        locals=locals@entry={'__builtins__': <module at remote 0x7ffff7fa1b08>, '__file__': '/usr/local/bin/fab', '__package__': None, 'sys': <module at remote 0x7ffff7fa1bb0>, 're': <module at remote 0x7ffff7ed32b8>, '__name__': '__main__', 'main': <function at remote 0x7ffff4e89aa0>, '__doc__': None}, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe1e0) at ../Python/pythonrun.c:1356
    #87 0x000000000046612d in PyRun_SimpleFileExFlags (fp=fp@entry=0x9ef390, filename=<optimized out>, filename@entry=0x7fffffffe66b "/usr/local/bin/fab", closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe1e0)
        at ../Python/pythonrun.c:948
    #88 0x0000000000466229 in PyRun_AnyFileExFlags (fp=fp@entry=0x9ef390, filename=filename@entry=0x7fffffffe66b "/usr/local/bin/fab", closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe1e0) at ../Python/pythonrun.c:752
    #89 0x0000000000466d92 in Py_Main (argc=<optimized out>, argv=0x7fffffffe398) at ../Modules/main.c:640
    #90 0x00007ffff7815f45 in __libc_start_main (main=0x466e50 <main>, argc=9, argv=0x7fffffffe398, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe388) at libc-start.c:287
    #91 0x0000000000577c2e in _start ()
    

    On psycopg2==2.7.1 we get the following segmentation fault:

    Program received signal SIGSEGV, Segmentation fault.
    __strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:209
    209	../sysdeps/x86_64/multiarch/../strcmp.S: No such file or directory.
    (gdb) bt
    #0  __strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:209
    #1  0x00007ffff6260699 in getrn (lh=lh@entry=0xa9eb60, data=data@entry=0x1030120, rhash=rhash@entry=0x7fffffff9da8) at lhash.c:432
    #2  0x00007ffff6260972 in lh_insert (lh=0xa9eb60, data=0x1030120) at lhash.c:189
    #3  0x00007ffff61dc8aa in OBJ_NAME_add (name=0x0, type=2, data=0x7ffff2869ec0 "\264\003") at o_names.c:207
    #4  0x00007ffff28f1ff7 in SSL_library_init () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/./libssl-cdf7ba29.so.1.0.2k
    #5  0x00007ffff2b62e9c in ?? () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-9c51d239.so.5.9
    #6  0x00007ffff2b505dd in PQconnectPoll () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-9c51d239.so.5.9
    #7  0x00007ffff2b50e3e in ?? () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-9c51d239.so.5.9
    #8  0x00007ffff2b516ef in PQconnectdb () from /usr/local/lib/python2.7/dist-packages/psycopg2/.libs/libpq-9c51d239.so.5.9
    #9  0x00007ffff2d8c241 in _conn_sync_connect (self=0x7ffff30bcc80) at psycopg/connection_int.c:716
    #10 conn_connect (self=self@entry=0x7ffff30bcc80, async=<optimized out>) at psycopg/connection_int.c:812
    #11 0x00007ffff2d8cf84 in connection_setup (async=<optimized out>, dsn=<optimized out>, self=0x7ffff30bcc80) at psycopg/connection_type.c:1277
    #12 connection_init (obj=obj@entry=<psycopg2.extensions.connection at remote 0x7ffff30bcc80>, args=args@entry=('port=5432 host=**censored ip** password=**censored password** dbname=postgres user=admin',), kwds=kwds@entry=0x0)
        at psycopg/connection_type.c:1362
    #13 0x000000000055f6db in type_call.25495 (type=<optimized out>, type@entry=0x7ffff2fab460 <connectionType>, args=args@entry=('port=5432 host=**censored ip** password=**censored password** dbname=postgres user=admin',), kwds=kwds@entry=0x0)
        at ../Objects/typeobject.c:745
    #14 0x00000000004c8a7d in PyObject_Call (kw=0x0, arg=('port=5432 host=**censored ip** password=**censored password** dbname=postgres user=admin',), func=<type at remote 0x7ffff2fab460>) at ../Objects/abstract.c:2529
    #15 call_function_tail.5417 (callable=callable@entry=<type at remote 0x7ffff2fab460>, args=('port=5432 host=**censored ip** password=**censored password** dbname=postgres user=admin',)) at ../Objects/abstract.c:2561
    #16 0x00000000005ab155 in _PyObject_CallFunction_SizeT (callable=<type at remote 0x7ffff2fab460>, format=format@entry=0x7ffff2da3f60 "s") at ../Objects/abstract.c:2605
    #17 0x00007ffff2d860b8 in psyco_connect (self=<optimized out>, args=<optimized out>, keywds=<optimized out>) at psycopg/psycopgmodule.c:111
    #18 0x000000000052714b in ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffc340, func=<built-in function _connect>) at ../Python/ceval.c:4330
    #19 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff302c850, for file /usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py, line 130, in connect (dsn='port=5432 host=**censored ip** password=**censored password** dbname=postgres user=admin', connection_factory=None, cursor_factory=None, kwargs={'port': 5432, 'host': '**censored ip**', 'password': '**censored password**', 'user': 'admin', 'database': 'postgres'}, kwasync={}), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #20 0x0000000000555551 in PyEval_EvalCodeEx (co=0x7ffff2ff5130, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=argcount@entry=0, kws=<optimized out>, kwcount=kwcount@entry=5, 
        defs=defs@entry=0x7ffff3018888, defcount=3, closure=0x0) at ../Python/ceval.c:3252
    #21 0x0000000000524338 in fast_function (nk=5, na=0, n=<optimized out>, pp_stack=0x7fffffffc530, func=<function at remote 0x7ffff300ff50>) at ../Python/ceval.c:4116
    #22 call_function (oparg=<optimized out>, pp_stack=0x7fffffffc530) at ../Python/ceval.c:4041
    #23 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xef3580, for file /home/ubuntu/workspace/external-database-create/awingu/clouddesktop-reposerver/fabfile/external_database/postgresql.py, line 21, in create_connection (connection_uri='postgresql://admin:**censored password**@**censored ip**:5432/', connection_args=<ParseResult(database='') at remote 0x7ffff2fbc8c0>), throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #24 0x0000000000567b1e in gen_send_ex.isra.0 (exc=0, arg=0x0) at ../Objects/genobject.c:85
    #25 gen_iternext (gen=0x7ffff301e730, gen@entry=<error reading variable: value has been optimized out>) at ../Objects/genobject.c:283
    #26 0x00000000004c96a9 in wrap_next.25272 (self=<optimized out>, args=<optimized out>, wrapped=<optimized out>) at ../Objects/typeobject.c:4683
    #27 0x00000000005244dd in PyObject_Call (kw=0x0, arg=(), func=<method-wrapper at remote 0x7ffff300ed90>) at ../Objects/abstract.c:2529
    #28 do_call (nk=<optimized out>, na=<optimized out>, pp_stack=0x7fffffffc6b0, func=<method-wrapper at remote 0x7ffff300ed90>) at ../Python/ceval.c:4238
    #29 call_function (oparg=<optimized out>, pp_stack=0x7fffffffc6b0) at ../Python/ceval.c:4043
    #30 PyEval_EvalFrameEx (f=f@entry=Frame 0x7ffff2fbb5c0, for file /usr/lib/python2.7/contextlib.py, line 17, in __enter__ (self=<GeneratorContextManager(gen=<generator at remote 0x7ffff301e730>) at remote 0x7ffff2ffaa50>), 
        throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #31 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-218384960, args=<optimized out>, locals=0x0, globals=<optimized out>, 
        co=<optimized out>) at ../Python/ceval.c:3252
    #32 function_call (func=func@entry=<function at remote 0x7ffff6af2c80>, arg=arg@entry=(<GeneratorContextManager(gen=<generator at remote 0x7ffff301e730>) at remote 0x7ffff2ffaa50>,), kw=kw@entry=0x0) at ../Objects/funcobject.c:526
    #33 0x00000000004c2604 in PyObject_Call (kw=0x0, arg=(<GeneratorContextManager(gen=<generator at remote 0x7ffff301e730>) at remote 0x7ffff2ffaa50>,), func=<function at remote 0x7ffff6af2c80>) at ../Objects/abstract.c:2529
    #34 instancemethod_call.8802 (func=<function at remote 0x7ffff6af2c80>, arg=(<GeneratorContextManager(gen=<generator at remote 0x7ffff301e730>) at remote 0x7ffff2ffaa50>,), kw=0x0) at ../Objects/classobject.c:2602
    #35 0x00000000004c6e74 in PyObject_Call (kw=0x0, arg=(), func=<instancemethod at remote 0x7ffff4810aa0>) at ../Objects/abstract.c:2529
    #36 PyObject_CallFunctionObjArgs (callable=callable@entry=<instancemethod at remote 0x7ffff4810aa0>) at ../Objects/abstract.c:2760
    #37 0x0000000000526020 in PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff300b638, for file /home/ubuntu/workspace/external-database-create/awingu/clouddesktop-reposerver/fabfile/external_database/postgresql.py, line 53, in delete_database (connection_uri='postgresql://admin:**censored password**@**censored ip**:5432/', database='nghtdef_frontend', hostname='**censored ip**'), throwflag=throwflag@entry=0) at ../Python/ceval.c:2555
    #38 0x00000000005247ea in fast_function (nk=<optimized out>, na=<optimized out>, n=2, pp_stack=0x7fffffffcd30, func=<function at remote 0x7ffff2fbc758>) at ../Python/ceval.c:4106
    ---Type <return> to continue, or q <return> to quit---
    #39 call_function (oparg=<optimized out>, pp_stack=0x7fffffffcd30) at ../Python/ceval.c:4041
    #40 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xef27f0, for file /home/ubuntu/workspace/external-database-create/awingu/clouddesktop-reposerver/fabfile/external_database/__init__.py, line 159, in delete (config={u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, connection_uri='postgresql://admin:**censored password**@**censored ip**:5432/', database_uris=('postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), connection_args=<ParseResult(database='') at remote 0x7ffff3070e60>, scheme=u'postgresql', delete_user=<function at remote 0x7ffff2fbc6e0>, delete_database=<function at remote 0x7ffff2fbc758>, exceptions=[], database_uri='postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', db_args=<ParseResult(database='nghtdef_frontend') at remote 0x7ffff2fbc7d0>), throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #41 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=15673328, args=<optimized out>, locals=0x0, globals=<optimized out>, 
        co=<optimized out>) at ../Python/ceval.c:3252
    #42 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #43 0x0000000000525cb7 in PyObject_Call (kw={}, 
        arg=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), func=<function at remote 0x7ffff3070c80>) at ../Objects/abstract.c:2529
    #44 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffcf30, func=<function at remote 0x7ffff3070c80>) at ../Python/ceval.c:4333
    #45 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff2fbb960, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 173, in run (self=<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff3070c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff3034e90>, args=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_fronte...(truncated), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #46 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-218384032, args=<optimized out>, locals=0x0, globals=<optimized out>, 
        co=<optimized out>) at ../Python/ceval.c:3252
    #47 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #48 0x0000000000525cb7 in PyObject_Call (kw={}, 
        arg=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff3070c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff3034e90>, {u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**...(truncated), func=<function at remote 0x7ffff50f4aa0>) at ../Objects/abstract.c:2529
    #49 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffd130, func=<function at remote 0x7ffff50f4aa0>) at ../Python/ceval.c:4333
    #50 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff2fbb790, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 170, in __call__ (self=<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff3070c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff3034e90>, args=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_f...(truncated), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #51 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-218384496, args=<optimized out>, locals=0x0, globals=<optimized out>, 
        co=<optimized out>) at ../Python/ceval.c:3252
    #52 function_call (func=func@entry=<function at remote 0x7ffff50f4a28>, 
        arg=arg@entry=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff3070c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff3034e90>, {u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**...(truncated), kw=kw@entry=0x0) at ../Objects/funcobject.c:526
    #53 0x00000000004c2604 in PyObject_Call (kw=0x0, 
        arg=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff3070c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff3034e90>, {u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**...(truncated), func=<function at remote 0x7ffff50f4a28>) at ../Objects/abstract.c:2529
    ---Type <return> to continue, or q <return> to quit---
    #54 instancemethod_call.8802 (func=<function at remote 0x7ffff50f4a28>, func@entry=<instancemethod at remote 0x7ffff4855140>, 
        arg=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff3070c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff3034e90>, {u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**...(truncated), 
        arg@entry=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), kw=kw@entry=0x0) at ../Objects/classobject.c:2602
    #55 0x00000000004d26cf in PyObject_Call (kw=0x0, 
        arg=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), func=<instancemethod at remote 0x7ffff4855140>)
        at ../Objects/abstract.c:2529
    #56 slot_tp_call.25849 (self=<optimized out>, 
        args=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), kwds=0x0) at ../Objects/typeobject.c:5432
    #57 0x0000000000525cb7 in PyObject_Call (kw=0x0, 
        arg=({u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, 'postgresql://admin:**censored password**@**censored ip**:5432/', 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'), 
        func=<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff3070c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff3034e90>) at ../Objects/abstract.c:2529
    #58 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffd650, 
        func=<WrappedCallableTask(__module__='fabfile.external_database', name='delete', is_default=False, wrapped=<function at remote 0x7ffff3070c80>, __name__='delete', __doc__='Delete one or more databases on an external database server.\n\n    Provide a connection_uri which can delete users and databases.\n    And one or more database_uri for the databases and users to be deleted.\n\n    The uri should be formatted as follows:\n    <scheme>://<username>:<password>@<hostname>[:<port>]/<database>\n    With scheme one of "postgresql", "mysql" or "mssql".\n    In the case of the connection_uri, there won\'t be a /<database> part.\n    ') at remote 0x7ffff3034e90>) at ../Python/ceval.c:4333
    #59 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff3118da8, for file /home/ubuntu/workspace/external-database-create/awingu/clouddesktop-reposerver/fabfile/external_database/__init__.py, line 74, in delete_all (config_name='postgresql', prefix='nghtdef', config={u'username': u'admin', u'conn_db': u'', u'protocol': u'postgresql', u'host': u'**censored ip**', u'import_path': u'postgresql', u'password': u'**censored password**', u'port': 5432}, connection_uri='postgresql://admin:**censored password**@**censored ip**:5432/', databases={'frontend_web': 'postgresql://nghtdef_frontend:nghtdef_frontend@**censored ip**:5432/nghtdef_frontend', 'graphite_web': 'postgresql://nghtdef_graphite:nghtdef_graphite@**censored ip**:5432/nghtdef_graphite'}), 
        throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #60 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-216953432, args=<optimized out>, locals=0x0, globals=<optimized out>, 
        co=<optimized out>) at ../Python/ceval.c:3252
    #61 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #62 0x0000000000525cb7 in PyObject_Call (kw={}, arg=('postgresql', 'nghtdef'), func=<function at remote 0x7ffff3070b90>) at ../Objects/abstract.c:2529
    #63 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffd850, func=<function at remote 0x7ffff3070b90>) at ../Python/ceval.c:4333
    #64 PyEval_EvalFrameEx (
        f=f@entry=Frame 0x7ffff2fbb3f0, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 173, in run (self=<WrappedCallableTask(__module__='fabfile.external_database', name='delete_all', is_default=False, wrapped=<function at remote 0x7ffff3070b90>, __name__='delete_all', __doc__=None) at remote 0x7ffff3034e10>, args=('postgresql', 'nghtdef'), kwargs={}), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #65 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=-218385424, args=<optimized out>, locals=0x0, globals=<optimized out>, 
        co=<optimized out>) at ../Python/ceval.c:3252
    #66 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #67 0x0000000000525cb7 in PyObject_Call (kw={}, 
        arg=(<WrappedCallableTask(__module__='fabfile.external_database', name='delete_all', is_default=False, wrapped=<function at remote 0x7ffff3070b90>, __name__='delete_all', __doc__=None) at remote 0x7ffff3034e10>, 'postgresql', 'nghtdef'), func=<function at remote 0x7ffff50f4aa0>) at ../Objects/abstract.c:2529
    #68 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffda50, func=<function at remote 0x7ffff50f4aa0>) at ../Python/ceval.c:4333
    #69 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xca61d0, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 276, in _execute (task=<WrappedCallableTask(__module__='fabfile.external_database', name='delete_all', is_default=False, wrapped=<function at remote 0x7ffff3070b90>, __name__='delete_all', __doc__=None) at remote 0x7ffff3034e10>, host='localhost', my_env={'clean_revert': True, 'all_hosts': ['localhost'], 'effective_roles': [], 'command': 'external_database.delete_all'}, args=('postgresql', 'nghtdef'), kwargs={}, jobs=<JobQueue(_finished=False, _queued=[], _running=[], _debug=False, _num_of_jobs=0, _closed=False, _max=1, _comms_queue=None, _completed=[]) at remote 0x7ffff3034f50>, queue=None, multiprocessing=None, local_env={'effective_roles': [...], 'all_hosts': [...], 'port': '22', 'clean_revert': True, 'host': 'localhost', 'command': 'external_database.delete_all', 'user': 'root', 'host_string': 'localhost'}), 
    ---Type <return> to continue, or q <return> to quit---
        throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #70 0x0000000000555551 in PyEval_EvalCodeEx (co=0x7ffff50bdf30, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=argcount@entry=8, kws=<optimized out>, kwcount=kwcount@entry=0, defs=defs@entry=0x0, 
        defcount=defcount@entry=0, closure=0x0) at ../Python/ceval.c:3252
    #71 0x0000000000525560 in fast_function (nk=0, na=8, n=<optimized out>, pp_stack=0x7fffffffdc40, func=<function at remote 0x7ffff50f4cf8>) at ../Python/ceval.c:4116
    #72 call_function (oparg=<optimized out>, pp_stack=0x7fffffffdc40) at ../Python/ceval.c:4041
    #73 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xf97530, for file /usr/local/lib/python2.7/dist-packages/fabric/tasks.py, line 386, in execute (task=<WrappedCallableTask(__module__='fabfile.external_database', name='delete_all', is_default=False, wrapped=<function at remote 0x7ffff3070b90>, __name__='delete_all', __doc__=None) at remote 0x7ffff3034e10>, args=('postgresql', 'nghtdef'), kwargs={'hosts': [], 'roles': [], 'exclude_hosts': []}, my_env={'clean_revert': True, 'all_hosts': ['localhost'], 'effective_roles': [], 'command': 'external_database.delete_all'}, results={}, is_callable=False, new_kwargs={}, hosts=[...], roles=[...], exclude_hosts=[...], parallel=False, multiprocessing=None, pool_size=1, queue=None, jobs=<JobQueue(_finished=False, _queued=[], _running=[], _debug=False, _num_of_jobs=0, _closed=False, _max=1, _comms_queue=None, _completed=[]) at remote 0x7ffff3034f50>, host='localhost'), throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #74 0x0000000000568b3a in PyEval_EvalCodeEx (closure=<optimized out>, defcount=<optimized out>, defs=0x0, kwcount=<optimized out>, kws=<optimized out>, argcount=16348464, args=<optimized out>, locals=0x0, globals=<optimized out>, 
        co=<optimized out>) at ../Python/ceval.c:3252
    #75 function_call (func=<optimized out>, arg=<optimized out>, kw=<optimized out>) at ../Objects/funcobject.c:526
    #76 0x0000000000525cb7 in PyObject_Call (kw={'hosts': [], 'roles': [], 'exclude_hosts': []}, arg=('external_database.delete_all', 'postgresql', 'nghtdef'), func=<function at remote 0x7ffff50f4de8>) at ../Objects/abstract.c:2529
    #77 ext_do_call (nk=<optimized out>, na=<optimized out>, flags=<optimized out>, pp_stack=0x7fffffffde40, func=<function at remote 0x7ffff50f4de8>) at ../Python/ceval.c:4333
    #78 PyEval_EvalFrameEx (
        f=f@entry=Frame 0xa138b0, for file /usr/local/lib/python2.7/dist-packages/fabric/main.py, line 756, in main (fabfile_locations=None, parser=<OptionParser(process_default_values=True, allow_interspersed_args=True, _long_opt={'--eagerly-disconnect': <Option(_long_opts=['--eagerly-disconnect'], help='disconnect from hosts as soon as possible', callback_args=None, callback=None, default=False, nargs=None, choices=None, dest='eagerly_disconnect', container=<...>, _short_opts=['-e'], action='store_true', const=None, callback_kwargs=None, type=None, metavar=None) at remote 0x7ffff533e3b0>, '--port': <Option(_long_opts=['--port'], help='SSH connection port', callback_args=None, callback=None, default='22', nargs=1, choices=None, dest='port', container=<...>, _short_opts=[], action='store', const=None, callback_kwargs=None, type='string', metavar=None) at remote 0x7ffff50cd950>, '--keepalive': <Option(_long_opts=['--keepalive'], help='enables a keepalive every N seconds', callback_args=None, callback=None, default=0, nargs=1, c...(truncated), throwflag=throwflag@entry=0) at ../Python/ceval.c:2705
    #79 0x0000000000555551 in PyEval_EvalCodeEx (co=0x7ffff7e9eab0, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=argcount@entry=0, kws=<optimized out>, kwcount=kwcount@entry=0, 
        defs=defs@entry=0x7ffff4e81968, defcount=1, closure=0x0) at ../Python/ceval.c:3252
    #80 0x0000000000524338 in fast_function (nk=0, na=0, n=<optimized out>, pp_stack=0x7fffffffe030, func=<function at remote 0x7ffff4e89aa0>) at ../Python/ceval.c:4116
    #81 call_function (oparg=<optimized out>, pp_stack=0x7fffffffe030) at ../Python/ceval.c:4041
    #82 PyEval_EvalFrameEx (f=f@entry=Frame 0x7ffff7e713e0, for file /usr/local/bin/fab, line 11, in <module> (), throwflag=throwflag@entry=0) at ../Python/ceval.c:2666
    #83 0x0000000000567d14 in PyEval_EvalCodeEx (closure=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=< at remote 0x7ffff7e71558>, 
        globals='Return true if the object is a user-defined function.\n\n    Function objects provide these attributes:\n        __doc__         documentation string\n        __name__        name with which this function was defined\n        func_code       code object containing compiled function bytecode\n        func_defaults   tuple of any default values for arguments\n        func_doc        (same as __doc__)\n        func_globals    global namespace in which this function was defined\n        func_name       (same as __name__)', co=0x7ffff7edb1b0) at ../Python/ceval.c:3252
    #84 PyEval_EvalCode (locals=< at remote 0x7ffff7e71558>, 
        globals='Return true if the object is a user-defined function.\n\n    Function objects provide these attributes:\n        __doc__         documentation string\n        __name__        name with which this function was defined\n        func_code       code object containing compiled function bytecode\n        func_defaults   tuple of any default values for arguments\n        func_doc        (same as __doc__)\n        func_globals    global namespace in which this function was defined\n        func_name       (same as __name__)', co=0x7ffff7edb1b0) at ../Python/ceval.c:667
    #85 run_mod.42576 (mod=mod@entry=0x977f18, filename=filename@entry=0x7fffffffe66b "/usr/local/bin/fab", 
        globals=globals@entry={'__builtins__': <module at remote 0x7ffff7fa1b08>, '__file__': '/usr/local/bin/fab', '__package__': None, 'sys': <module at remote 0x7ffff7fa1bb0>, 're': <module at remote 0x7ffff7ed32b8>, '__name__': '__main__', 'main': <function at remote 0x7ffff4e89aa0>, '__doc__': None}, 
        locals=locals@entry={'__builtins__': <module at remote 0x7ffff7fa1b08>, '__file__': '/usr/local/bin/fab', '__package__': None, 'sys': <module at remote 0x7ffff7fa1bb0>, 're': <module at remote 0x7ffff7ed32b8>, '__name__': '__main__', 'main': <function at remote 0x7ffff4e89aa0>, '__doc__': None}, flags=flags@entry=0x7fffffffe1e0, arena=arena@entry=0x9a4a80) at ../Python/pythonrun.c:1370
    #86 0x0000000000465bf4 in PyRun_FileExFlags (fp=fp@entry=0x9ef390, filename=filename@entry=0x7fffffffe66b "/usr/local/bin/fab", start=start@entry=257, 
        globals=globals@entry={'__builtins__': <module at remote 0x7ffff7fa1b08>, '__file__': '/usr/local/bin/fab', '__package__': None, 'sys': <module at remote 0x7ffff7fa1bb0>, 're': <module at remote 0x7ffff7ed32b8>, '__name__': '__main__', 'main': <function at remote 0x7ffff4e89aa0>, '__doc__': None}, 
        locals=locals@entry={'__builtins__': <module at remote 0x7ffff7fa1b08>, '__file__': '/usr/local/bin/fab', '__package__': None, 'sys': <module at remote 0x7ffff7fa1bb0>, 're': <module at remote 0x7ffff7ed32b8>, '__name__': '__main__', 'main': <function at remote 0x7ffff4e89aa0>, '__doc__': None}, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe1e0) at ../Python/pythonrun.c:1356
    #87 0x000000000046612d in PyRun_SimpleFileExFlags (fp=fp@entry=0x9ef390, filename=<optimized out>, filename@entry=0x7fffffffe66b "/usr/local/bin/fab", closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe1e0)
        at ../Python/pythonrun.c:948
    #88 0x0000000000466229 in PyRun_AnyFileExFlags (fp=fp@entry=0x9ef390, filename=filename@entry=0x7fffffffe66b "/usr/local/bin/fab", closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe1e0) at ../Python/pythonrun.c:752
    #89 0x0000000000466d92 in Py_Main (argc=<optimized out>, argv=0x7fffffffe398) at ../Modules/main.c:640
    #90 0x00007ffff7815f45 in __libc_start_main (main=0x466e50 <main>, argc=9, argv=0x7fffffffe398, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe388) at libc-start.c:287
    #91 0x0000000000577c2e in _start ()
    
    wheel 
    opened by rubendv 34
  • psycopg2-binary: Why?

    psycopg2-binary: Why?

    Forgive the blunt question but I cannot find discussion on why the split of psycopg2 and psycopg2-binary is happening. The current (2.7) way of doing wheel+source distribution works exactly how it's supposed to. Splitting into a separate -binary distribution actually breaks any library that depends on psycopg2=>2.x, which includes for example sqlalchemy's postgres bindings, because setuptools will complain the dependency is not matched.

    wheel 
    opened by jleclanche 33
  • (DatabaseError) error with no message from the libpq

    (DatabaseError) error with no message from the libpq

    Hi guys, I get randomly this error: The stack is flask with sqlalchemy and postgres.

    Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engin/base.py", line 951, in _execute_context context) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engin/default.py", 
    line 436, in do_execute cursor.execute(statement, parameters)
    psycopg2.DatabaseError: error with no message from the libpq The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/flask/app.py", 
    line 1817, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.4/dist-packages/flask/app.py", 
    line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.4/dist-packages/flask/app.py", 
    line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.4/dist-packages/flask/_compat.py", 
    line 33, in reraise raise value File "/usr/local/lib/python3.4/dist-packages/flask/app.py", 
    line 1475, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.4/dist-packages/flask/app.py", 
    line 1461, in dispatch_request return self.view_functionsrule.endpoint File "./main/views.py", 
    line 63, in auth_login user = User.query.filter_by(username=username).first() File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/query.py", 
    line 2367, in first ret = list(self[0:1]) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/query.py", 
    line 2228, in getitem return list(res) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/query.py", 
    line 2438, in iter return self._execute_and_instances(context) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/orm/query.py", 
    line 2453, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", 
    line 729, in execute return meth(self, multiparams, params) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/elements.py", 
    line 322, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", 
    line 826, in _execute_clauseelement compiled_sql, distilled_params File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", 
    line 958, in _execute_context context) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", 
    line 1159, in _handle_dbapi_exception exc_info File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/util/compat.py", line 188, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=exc_value) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/util/compat.py", 
    line 181, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", 
    line 951, in _execute_context context) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/default.py", 
    line 436, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.DatabaseError (DatabaseError) error with no message from the libpq 'SELECT users.id AS users_id, users.username AS users_username, users.first_name AS users_first_name, users.last_name AS users_last_name, users.password AS users_password, users.status AS users_status, users.is_staff AS users_is_staff, users.user_plan AS users_user_plan, users.last_login AS users_last_login, users.date_joined AS users_date_joined, users.reset_password_token AS users_reset_password_token \nFROM users \nWHERE users.username = %(username_1)s \n LIMIT %(param_1)s' {'username_1': '[email protected]', 'param_1': 1}
    
    opened by barrachri 31
  • database connection isn't set to UTC

    database connection isn't set to UTC

    tl; dr: if you are using Django 2.2 you must use psycopg < 2.9 in your requirements file.


    I just add this error after an upgrade. It's probably right about my database not being in UTC but I don't see the problem.

    venv/bin/pip install -U psycopg2
    Collecting psycopg2
      Downloading psycopg2-2.9.tar.gz (379 kB)
         |████████████████████████████████| 379 kB 7.2 MB/s 
    Building wheels for collected packages: psycopg2
      Building wheel for psycopg2 (setup.py) ... done
      Created wheel for psycopg2: filename=psycopg2-2.9-cp36-cp36m-linux_x86_64.whl size=473570 sha256=c01f7407f6cc56a729d8693eb62133f284c8612b0ae0ef109d8bfa01ba5441d6
      Stored in directory: /home/test2/.cache/pip/wheels/70/01/46/39007954b343d1d72463a755e6a74e6106b10748fe22e2058b
    Successfully built psycopg2
    Installing collected packages: psycopg2
      Attempting uninstall: psycopg2
        Found existing installation: psycopg2 2.8.6
        Uninstalling psycopg2-2.8.6:
          Successfully uninstalled psycopg2-2.8.6
    Successfully installed psycopg2-2.9
    
    opened by plup 28
  • pip install of psycopg2 on Mac OS X El Capitan results in unusable build

    pip install of psycopg2 on Mac OS X El Capitan results in unusable build

    Please see this Stack Overflow question:

    http://stackoverflow.com/questions/32978365/how-do-i-run-psycopg2-on-el-capitan-without-hitting-a-libssl-error

    ArtHarg's answer worked for me, and suggests it may be possible to fix this on the psycopg2 side. Please let me know what I can do to help!

    opened by cjw296 28
  • Add support for PG_DIAG_*_NAME error fields

    Add support for PG_DIAG_*_NAME error fields

    Originally submitted by: masklinn

    While not released yet, Postgres 9.3 (to be released in September 2013?) will apparently add a number of error fields useful for programmatic analysis and manipulation of errors: http://www.postgresql.org/docs/devel/static/libpq-exec.html

    • PG_DIAG_SCHEMA_NAME
    • PG_DIAG_TABLE_NAME
    • PG_DIAG_COLUMN_NAME
    • PG_DIAG_DATATYPE_NAME
    • PG_DIAG_CONSTRAINT_NAME

    Considering the usefulness of these, especially in application-type scenarios, I think it'd be nice if psycopg exposed them on its exceptions on day0 of the corresponding postgres release.

    opened by psycoteam 28
  • Connection fails with psycopg2-binary v. 2.9.5 and ssl required

    Connection fails with psycopg2-binary v. 2.9.5 and ssl required

    When using django and psycopg2-binary 2.9.5 to connect to a postgres database with ssl=required the following error is thrown:

    connection to server at [...] failed: could not open certificate file "/root/.postgresql/postgresql.crt": Permission denied

    With 2.9.4 this seems to just run fine.

    Tested with python 3.8.

    opened by 21adrian1996 3
  • Incorrect SQL operation with cursor.callproc()

    Incorrect SQL operation with cursor.callproc()

    Version Info

    • OS: macOS 12.6.2 / Windows 11
    • Psycopg version: 2.9.5 (dt dec pq3 ext lo64)
    • Python version: 3.10.7
    • PostgreSQL version: 14.5 (x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit)
    • pip version: 22.3.1

    Bug In python, when I ran the following code:

    import psycopg2
    conn = psycopg2.connect("dsn string")
    cur = conn.cursor()
    cur.callproc('proc_name', ['1000'])
    # also tried:
    cur.callproc('proc_name', ('1000',))
    

    I get the following error:

    psycopg2.errors.WrongObjectType: proc_name(unknown) is a procedure
    LINE 1: SELECT * FROM proc_name('1000')
    

    I notice that instead of CALL the callproc() use SELECT to handle the request.

    The procedure proc_name is defined as:

    begin
    
    -- PREPARE RSID_LINK_INSERT (VARCHAR(100)) AS
    -- INSERT INTO id_search(search_rsid, date) VALUES($1, current_date) 
    -- ON CONFLICT (search_rsid) DO UPDATE
    -- SET date = current_date;
    	
    -- EXECUTE RSID_LINK_INSERT(RSID);
    
    INSERT INTO id_search(search_rsid, date) 
    VALUES(RSID, current_date);
    -- ON CONFLICT (search_rsid) DO UPDATE
    -- SET date = current_date;
    Commit;
    
    end;
    

    The table id_search has two columns, where the first one is string with max 11 chars, the second column is date.

    The documentation of callproc states callproc(procname, parameters=None) -- Execute stored procedure., while the online documentation says function instead of procedure should be executed with callproc. I think either the documentation should be updated, or the behaviour of callproc itself should be corrected.

    opened by jimmymcheung 0
  • Regression test failure with PG 15.1: tests/test_connection.py: AssertionError: [] is not true

    Regression test failure with PG 15.1: tests/test_connection.py: AssertionError: [] is not true

    It looks that #1506 is back - Pycopg2 2.9.5, PostgreSQL 15.1, Debian unstable/amd64:

    FAIL: test_ssl_attribute (tests.test_connection.TestConnectionInfo)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/cbe/projects/postgresql/psycopg2/psycopg2/.pybuild/cpython3_3.10_psycopg2/build/tests/test_connection.py", line 1925, in test_ssl_attribute
        self.assert_(attribs)
    AssertionError: [] is not true
    

    The culprit seems to be postgres/postgres@cae4688ce8.

    opened by df7cb 3
  • psycopg2.OperationalError: PQexec not allowed during COPY BOTH when running drop_replication_slot

    psycopg2.OperationalError: PQexec not allowed during COPY BOTH when running drop_replication_slot

    This is a bug tracker

    Please complete the following information:

    • OS: Docker image - FROM python:3.9-slim-buster
    • Psycopg version: psycopg2-binary==2.9.3
    • Python version: 3.9
    • PostgreSQL version: 11.13
    • pip version: pip 22.0.4

    Describe the bug

    We are trying logical replication on a Postgres RDS, and are running a docker image on ECS to consume the wal2json data. We have a timeout condition to drop the replication slot, before exiting the process, so that we don't run out of storage on the RDS. We tried using cur.consume_stream previously, and we saw that eventually the image would be running for some time without printing anything, and storage on the RDS would explode.

    When running cur.drop_replication_slot('wal2json_test_slot')

    We get

    File "/usr/local/lib/python3.9/site-packages/psycopg2/extras.py", line 563, in drop_replication_slot  
    self.execute(command)  
    psycopg2.OperationalError: PQexec not allowed during COPY BOTH
    

    The slot does seem to drop successfully, so I don't know why we get this error in our logs.

    The script:

    def consume(msg):
        print("Attempting to put to Kinesis")
        kinesis_client.put_record(StreamName=STREAM_NAME, Data=msg.payload, PartitionKey="default")
        msg.cursor.send_feedback(flush_lsn=msg.data_start)
        print("Success")
    
    cur = my_connection.cursor()
    try:
        print("Attempting to drop old replication slot")
        cur.drop_replication_slot('wal2json_test_slot')
        print("Old replication slot dropped")
    except:
        pass
    cur.create_replication_slot('wal2json_test_slot', output_plugin = 'wal2json')
    cur.start_replication(slot_name = 'wal2json_test_slot', options = {'pretty-print' : 0}, decode= True)
    
    # cur.consume_stream(consume)
    
    last_msg_time = datetime.now()
    status_interval = 10.0
    
    print("Starting Replication")
    while True:
        print("Checking for messages")
        if datetime.now() - last_msg_time > timedelta(minutes=10):
            print("Not received a message in 10 minutes, dropping replication slot and exiting")
            cur.drop_replication_slot('wal2json_test_slot')
            sys.exit()
        msg = cur.read_message()
        if msg:
            last_msg_time = msg.send_time
            print(f"Message received at: {last_msg_time.isoformat()}")
            consume(msg)
        else:
            print("No message received, waiting")
            now = datetime.now()
            timeout = status_interval - (now - cur.feedback_timestamp).total_seconds()
            sel = select([cur], [], [], max(0, timeout))
    opened by AzeemIqbal 7
  • Empty OperationalError when I tried to connect with wrong credentials

    Empty OperationalError when I tried to connect with wrong credentials

    This is a bug tracker If you have a question, such has "how do you do X with Python/PostgreSQL/psycopg2" please write to the mailing list or open a question instead.

    Please complete the following information:

    • OS: Windows 8
    • Psycopg version: 2.9.3
    • Python version: 3.10.4
    • PostgreSQL version: PostgreSQL 14.2, compiled by Visual C++ build 1914, 64-bit
    • pip version: 22.0.4

    Describe the bug When I tried to connect to database with wrong credentials, I did not a descriptive message about the problem. By the way, some time ago another user reported the same problem (Empty OperationalError on connect #417) but, until now there is not any solution (the issue was closed).

    Please let us know:

    1: what you did

    • I defined two variables that wraps the credentials to connect to PostgreSQL database
    • I defined a variable to receive the connection
       import psycopg2
       import os
       
       try:
           USER = os.environ['postgres']
           PASSWORD = os.environ['xyz1'] #Password is wrong
           conn = psycopg2.connect(host="localhost", port="5432", database="exampleDB", user=USER, password=PASSWORD)
           .....
    
       except psycopg2.OperationalError as err:
           print("Error: ", err)
           conn = None
    
       finally:
           if conn is not None:
               conn.close
    

    2: what you expected to happen

    • A descriptive message showing what happend

    3: what happened instead

    • I just got hardcode string 'Error:'

    If possible, provide a script reproducing the issue.

    opened by luisrojas17 8
  • Support for passing in existing SSL connection to psycopg2.connect()

    Support for passing in existing SSL connection to psycopg2.connect()

    The Cloud SQL Python Connector would like to support database connections to Cloud SQL using psycopg2. In order to do so we require the ability to pass in an existing connection or the ability to configure the connection level SSL.

    For reference, we currently support pg8000 through the use of their ssl_context argument which allows us to pass in our pre-configured ssl.SSLContext object. pg8000 ssl_context

    Let me know if this is potentially feasible in a future release? Happy to provide more information or assistance if needed. Thanks!

    opened by jackwotherspoon 1
Owner
The Psycopg Team
We make reptiles and pachiderms talk to each other.
The Psycopg Team
A fast PostgreSQL Database Client Library for Python/asyncio.

asyncpg -- A fast PostgreSQL Database Client Library for Python/asyncio asyncpg is a database interface library designed specifically for PostgreSQL a

magicstack 5.8k Dec 31, 2022
PostgreSQL database access simplified

Queries: PostgreSQL Simplified Queries is a BSD licensed opinionated wrapper of the psycopg2 library for interacting with PostgreSQL. The popular psyc

Gavin M. Roy 251 Oct 25, 2022
aiopg is a library for accessing a PostgreSQL database from the asyncio

aiopg aiopg is a library for accessing a PostgreSQL database from the asyncio (PEP-3156/tulip) framework. It wraps asynchronous features of the Psycop

aio-libs 1.3k Jan 3, 2023
Pure-python PostgreSQL driver

pg-purepy pg-purepy is a pure-Python PostgreSQL wrapper based on the anyio library. A lot of this library was inspired by the pg8000 library. Credits

Lura Skye 11 May 23, 2022
A Python wheel containing PostgreSQL

postgresql-wheel A Python wheel for Linux containing a complete, self-contained, locally installable PostgreSQL database server. All servers run as th

Michel Pelletier 71 Nov 9, 2022
Application which allows you to make PostgreSQL databases with Python

Automate PostgreSQL Databases with Python Application which allows you to make PostgreSQL databases with Python I used the psycopg2 library which is u

Marc-Alistair Coffi 0 Dec 31, 2021
a small, expressive orm -- supports postgresql, mysql and sqlite

peewee Peewee is a simple and small ORM. It has few (but expressive) concepts, making it easy to learn and intuitive to use. a small, expressive ORM p

Charles Leifer 9.7k Dec 30, 2022
Pandas on AWS - Easy integration with Athena, Glue, Redshift, Timestream, QuickSight, Chime, CloudWatchLogs, DynamoDB, EMR, SecretManager, PostgreSQL, MySQL, SQLServer and S3 (Parquet, CSV, JSON and EXCEL).

AWS Data Wrangler Pandas on AWS Easy integration with Athena, Glue, Redshift, Timestream, QuickSight, Chime, CloudWatchLogs, DynamoDB, EMR, SecretMana

Amazon Web Services - Labs 3.3k Dec 31, 2022
MySQL database connector for Python (with Python 3 support)

mysqlclient This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs. PyPI: https://pypi.org/project/mysqlclient/ Gi

PyMySQL 2.2k Dec 25, 2022
MySQL database connector for Python (with Python 3 support)

mysqlclient This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs. PyPI: https://pypi.org/project/mysqlclient/ Gi

PyMySQL 2.2k Dec 25, 2022
Python interface to Oracle Database conforming to the Python DB API 2.0 specification.

cx_Oracle version 8.2 (Development) cx_Oracle is a Python extension module that enables access to Oracle Database. It conforms to the Python database

Oracle 841 Dec 21, 2022
Async database support for Python. 🗄

Databases Databases gives you simple asyncio support for a range of databases. It allows you to make queries using the powerful SQLAlchemy Core expres

Encode 3.2k Dec 30, 2022
The Database Toolkit for Python

SQLAlchemy The Python SQL Toolkit and Object Relational Mapper Introduction SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that giv

SQLAlchemy 6.5k Jan 1, 2023
A HugSQL-inspired database library for Python

PugSQL PugSQL is a simple Python interface for using parameterized SQL, in files. See pugsql.org for the documentation. To install: pip install pugsql

Dan McKinley 558 Dec 24, 2022
A tiny python web application based on Flask to set, get, expire, delete keys of Redis database easily with direct link at the browser.

First Redis Python (CRUD) A tiny python web application based on Flask to set, get, expire, delete keys of Redis database easily with direct link at t

Max Base 9 Dec 24, 2022
A Relational Database Management System for a miniature version of Twitter written in MySQL with CLI in python.

Mini-Twitter-Database This was done as a database design course project at Amirkabir university of technology. This is a relational database managemen

Ali 12 Nov 23, 2022
Database connection pooler for Python

Nimue Strange women lying in ponds distributing swords is no basis for a system of government! --Dennis, Peasant Nimue is a database connection pool f

null 1 Nov 9, 2021
A tutorial designed to introduce you to SQlite 3 database using python

SQLite3-python-tutorial A tutorial designed to introduce you to SQlite 3 database using python What is SQLite? SQLite is an in-process library that im

null 0 Dec 28, 2021
Creating a python package to convert /transfer excelsheet data to a mysql Database Table

Creating a python package to convert /transfer excelsheet data to a mysql Database Table

Odiwuor Lameck 1 Jan 7, 2022