user29349326
user29349326

Reputation: 1

Connection issue when launching python program with Talend Data Integration tSystem

I'm using Talend tSystem componant to launch a python file (e.g. file.py), using anaconda interpreter. I wrote a program, which works perfectly using VsCode, but does not work using Talend tSystem. I'm sure the program is well launched because it succeeded to print something, but as soon as I want to connect to a sqlalchemy engine, it stops working

When just writing print('hello') within file.py, Talend console effectively prints "hello", meaning the program is well running. That's a good start ^^.

Now, I want to run the full program, which consists to connect to a postgresql database, execute a SELECT sql request and log elements

db = Databases()

def main():
    cursor = db.my_method()
    print("cursor ok")
    records = cursor.fetchall()
    for row in records:
        a, b, c = row
        logging.info(a, b, c)
    cursor.close()

if __name__ == "__main__":
    main()

The method inside Databases:

class Databases:
    def my_method(self):
        sql= "SQL_REQUEST"
        engine = create_engine('postgresql://****')
        print(engine.url)
        with engine.connect() as connection:
            print("connection successfull")
            return connection.execute(text(sql))

When running using VsCode, it works perfectly. When running using Talend, it does not work, meaning it creates logging file, but it does not fill it with values inside "row". Worse, it does not print anything anymore.

I tried to know where the program stoppped by commenting rows and uncommenting rows one by one. It succeeds to print engine.url in Talend output console, which is correct by the way, but as soon as I uncomment "with engine.connect() as connection:", it stops to print anything, and of course the programs failed.

Any help for this ? Thanks a lot

EDIT: resolved. That was because I launched VsCode directly via Anaconda, which get the good python interpreter. I cleaned all my python versions and added environment variables to launch Anaconda env directly via Powershell, and therefore via Talend

Upvotes: 0

Views: 23

Answers (0)

Related Questions