Vertica Python Connection
<p>I'm trying to connect to a Vertica database via Python. Here is what I have so far.</p>

<p>Using <code>vertica_python</code>:</p>

<pre><code>! pip install vertica_python
from vertica_python import connect
conn_info = {'host': '192.168...',
             'port': my_port_number,
             'user': 'my_uid',
             'password': 'my_pwd',
             'database': 'my_dbname',
             # 10 minutes timeout on queries
             'read_timeout': 600,
             # default throw error on invalid UTF-8 results
             'unicode_error': 'strict',
             # SSL is disabled by default
             'ssl': False}
connection = vertica_python.connect(**conn_info)
</code></pre>

<p>Gives the following error:</p>

<pre><code>---------------------------------------------------------------------------
ConnectionError                           Traceback (most recent call last)
&lt;ipython-input-3-629986180e1e&gt; in &lt;module&gt;()
----&gt; 1 connection = connect(host = "192.168...", port = my_port_number, user = 'my_uid', password ='my_pwd', database = 'my_dbname')

/Users/MyUserName/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/vertica_python/__init__.pyc in connect(**kwargs)
     28 def connect(**kwargs):
     29     """Opens a new connection to a Vertica database."""
---&gt; 30     return Connection(kwargs)

/Users/MyUserName/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/vertica_python/vertica/connection.pyc in __init__(self, options)
     36         self.options.setdefault('port', 5433)
     37         self.options.setdefault('read_timeout', 600)
---&gt; 38         self.startup_connection()
     39 
     40     def __enter__(self):

/Users/MyUserName/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/vertica_python/vertica/connection.pyc in startup_connection(self)
    255 
    256         while True:
--&gt; 257             message = self.read_message()
    258 
    259             if isinstance(message, messages.Authentication):

/Users/MyUserName/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/vertica_python/vertica/connection.pyc in read_message(self)
    190                     "Bad message size: {0}".format(size)
    191                 )
--&gt; 192             message = BackendMessage.factory(type_, self.read_bytes(size - 4))
    193             logger.debug('&lt;= %s', message)
    194             return message

/Users/MyUserName/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/vertica_python/vertica/connection.pyc in read_bytes(self, n)
    242             bytes_ = self._socket().recv(n - len(results))
    243             if not bytes_:
--&gt; 244                 raise errors.ConnectionError("Connection closed by Vertica")
    245             results = results + bytes_
    246         return results

ConnectionError: Connection closed by Vertica
</code></pre>

<p>Using <code>jaydebeapi</code> gives a different error:</p>

<pre><code>! pip install jaydebeapi
import jaydebeapi
connection = jaydebeapi.connect('com.vertica.Driver', ['jdbc:vertica://...','my_uid','my_pwd'], '/Users/MyUserName/Documents/JAR Files/vertica-jdbc-4.1.14.jar')
RuntimeError: Unable to load DLL [/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libjvm.dylib], error = dlopen(/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libjvm.dylib, 9): no suitable image found.  Did find:
/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libjvm.dylib: mach-o, but wrong architecture at native/common/include/jp_platform_linux.h:45 
</code></pre>

<p>Lastly, I tried <code>pyodbc</code> but I'm not able to even import it:</p>

<pre><code>! pip install pyodbc
import pyodbc
ImportError: dlopen(/Users/MyUserName/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyodbc.so, 2): Library not loaded: /usr/local/lib/libodbc.2.dylib
  Referenced from: /Users/MyUserName/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pyodbc.so
  Reason: image not found 
</code></pre>

<p>I'm new to Python so any help is much appreciated</p>

<p>You can pass key/value pair like that in Python.</p>

<p>Use as follow:</p>

<pre><code>from vertica_python import connect
connection = connect(
    host='jdbc:vertica://...',
    port=my_port_number,
    user='my_uid',
    password='my_pwd'
    )
</code></pre>

python database-connectivity