Can someone let me know the steps to connect Denodo from python ?
Actually I have a view in Denodo which I need to call from Python and load into CSV file.
Using psycopg2 python adapter, we can connect Denodo Postgresql driver to read the Denodo view. Below are the sample code
import psycopg2 import time def iter_row(cursor, size=10): while True: rows = cursor.fetchmany(size) if not rows: break for row in rows: yield row def get_data(): """ query part and vendor data from multiple tables""" conn = None try: # params = config() start_time = time.time() conn = psycopg2.connect("dbname = 'db' user = 'admin' host = 'localhost' password = 'pwd' port='9996'") cur = conn.cursor() cur.execute(""" select * from denodo_view """) # i = 0 with open('file.csv', 'w',encoding="utf-8") as f: for row in iter_row(cur, 100000): f.write("%s\n" % str(row)) # i += 1 # print(i) f.close() cur.close() except (Exception, psycopg2.DatabaseError) as error: print(error) finally: if conn is not None: # end_time = time.time() conn.close() print(time.time() - start_time) if __name__ == '__main__': get_data()