Get column names (title) from a Vertica data base?
<p>I'm trying to extract the column names when pulling data from a vertica data base in python via an sql query. I am using vertica-python 0.6.8. So far I am creating a dictionary of the first line, but I was wondering if there is an easier way of doing it. This is how I am doing it right now:</p>

<pre><code>import vertica_python
import csv
import sys
import ssl
import psycopg2

conn_info = {'host': '****',
             'port': 5433,
             'user': '****',
             'password': '****',
             'database': '****',
             # 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)
cur = connection.cursor('dict')
str = "SELECT * FROM something WHERE something_happens LIMIT 1"
cur.execute(str)
temp = cur.fetchall()
ColumnList = []
for column in temp[0]:
    ColumnList.append(column)
</code></pre>

<p>cheers</p>

<p>If I am not wrong you are asking about the title of each column.
You can do that by using data descriptors of "class hp_vertica_client.cursor".
It can be found here :
<a href="https://my.vertica.com/docs/7.2.x/HTML/Content/python_client/cursor.html" rel="nofollow">https://my.vertica.com/docs/7.2.x/HTML/Content/python_client/cursor.html</a></p>

python vertica