How to connect from Python to Denodo

Submitted 11 months, 4 weeks ago
Ticket #438
Views 180
Language Other
Priority Low
Status In-Progress

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.

Submitted on Feb 14, 22
add a comment

1 Answer

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:
        for row in rows:
            yield row

def get_data():
    """ query part and vendor data from multiple tables"""
    conn = None
        # params = config()
        start_time = time.time()
        conn = psycopg2.connect("dbname = 'db' user = 'admin' host = 'localhost' password = 'pwd' port='9996'")
        cur = conn.cursor()
            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)
    except (Exception, psycopg2.DatabaseError) as error:
        if conn is not None:
            # end_time =  time.time()
            print(time.time() - start_time)

if __name__ == '__main__':

Submitted 11 months, 4 weeks ago

Wanna Post Ad?
Reach a large group of audience by posting an ad about your business here. For more details
Drop us a Message