0

I am able to connect to aws-redshift with psycopg2 using python, I can query tables and get data back, etc...

However, when I try to run a create udf fucntion through psycopg2, nothing happens, no error returns but nothing gets created.

Here's my code:

def _applyFunctionToDB():
    con=psycopg2.connect(dbname = redhsiftDatabase, host = redshiftHost, port = '5439', user = redshiftUser, password = redshiftPwd)
    cur = con.cursor()
    udf=_fileOpenWrite(udfFile)
    size = os.stat(udfFile).st_size
    udfCode=udf.read(size)
    cur.execute(udfCode)
    con.close()

I have run it through the debugger and all the pieces are there, but nothing happens when the "execute" method is invoked on the cursor.

If anyone has any advice and/or ideas on what might be going on here, please advise.

Thanks!

EricBlair1984
  • 339
  • 4
  • 16

1 Answers1

0

found answer just after posting here: Copying data from S3 to AWS redshift using python and psycopg2

I need to invoke a commit.

So, add con.commit in above code after execute.

Community
  • 1
  • 1
EricBlair1984
  • 339
  • 4
  • 16