Closed patatwork365 closed 1 year ago
Hi @patatwork365 ,
I was able to reproduce this issue locally. When stepping through redshift-connector's code with the debugger I was able to identify the issue and a workaround for it: tl;dr add quotes around the role name.
conn = redshift_connector.connect(host=host, database=database, user=user, password=password)
sql = 'grant role "sys:dba" to theallpowerful;'
conn.run(sql)
You've identified an underlying bug in redshift_connector. By default, on a module level redshift_connector is configured to use format paramstyle. When looking with the debugger, this error occurred because the Cursor object on the connection has a default paramstyle of named (which looks for colons), hence the weird error you saw as redshift_connector thought it was a bind parameter.
I think there are a few things going on here that should be looked into:
.execute()
, why are we messing with bind parameters? Unless I'm missing something this just adds overhead.2 would be a break in existing behavior for users, so I'm more inclined towards looking into 1 as a possible work around.
Thanks @Brooke-white , I'd already found the quoted workaround and works fine in this instance.
We generate a lot statements from metadata so always nice if they work cleanly and without workarounds which can cause other downstream such as quoted identifiers case mismatch.
completely agreed. we will put a fix for this issue in our next release.
release 2.0.911 includes a fix for this, thank you for your patience
Driver version
redshift-connector 2.0.910
Redshift version
(['PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.49087\x00\x00'],)
Client Operating System
Description: Amazon Linux release 2 (Karoo)
Python version
Python 3.7.16
Problem description
Will not process sql to grant/revoke built in roles such as sys:dba
Reproduction code