how to ingest data into Vertica from a web service.
Guys,
i have a web service client which is coded in python. It is basically a api to a data storage service.
Is it possible to some how utilize the web api service client so that it feeds data to vertica or conversely use vertica to pick up data from the api service.
Regards,
Anmol
i have a web service client which is coded in python. It is basically a api to a data storage service.
Is it possible to some how utilize the web api service client so that it feeds data to vertica or conversely use vertica to pick up data from the api service.
Regards,
Anmol
0
Comments
Hello Anmol,
It is certainly possible to use Python to connect to and query Vertica. You will need to download and install pyodbc module and HP Vertica ODBC (Vertica ODBC is available at https://my.vertica.com/download-community-edition/)
For general information and examples of using Python with Vertica, please refer to:
https://my.vertica.com/docs/7.0.x/HTML/index.htm#Authoring/ProgrammersGuide/ClientPerl-Python/Progra....
https://my.vertica.com/docs/7.0.x/HTML/index.htm#Authoring/ProgrammersGuide/ClientPerl-Python/Queryi....
Regards,
Han
Hello Anmol,
I followed steps below and have successfully configured Python (on Windows) to connect to and query Vertica:
1. Download and install appropriate client package for Vertica (64 or 32 bits). The package can be downloaded from https://my.vertica.com/download-community-edition/
2. Follow the document on this page to configure a DSN for the ODBC driver: https://my.vertica.com/docs/7.0.x/HTML/index.htm#Authoring/ProgrammersGuide/ClientODBC/SettingUpADSN...
3. Download and install appropriate version of Python (64 or 32 bits). HP Vertica's ODBC driver is tested with Python version 2.4. It should work with versions 2.4 through 2.7.
4. Download and install appropriate version of Python ODBC (64 or 32 bits) from http://code.google.com/p/pyodbc/
5. After successfully configuring the above, the following test code can be used to test Python connection to Vertica:
import pyodbc
query = "SELECT * FROM <your_table>"
conn = pyodbc.connect('<your_DSN in step 2>', ansi=True)
cursor = conn.cursor()
cursor.execute(query)
rows = cursor.fetchall()
for row in rows:
print row[0]
print row[1]
query2 = "create table pyTest(firstName varchar(20), lastName varchar(50))"
query3 = "insert into pyTest values('Tom', 'Hanks')"
query4 = "commit"
query5 = "select * from pyTest"
cursor.execute(query2)
cursor.execute(query3)
cursor.execute(query4)
cursor.execute(query5)
rows = cursor.fetchall()
for row in rows:
print row[0]
print row[1]
Hope this helped.
Regards,
Han