mfenniak / pg8000

A Pure-Python PostgreSQL Driver
http://pythonhosted.org/pg8000/
Other
222 stars 55 forks source link

Amazon Redshift rowcount #181

Closed dburtsev closed 3 years ago

dburtsev commented 3 years ago

Hello

Is it possible to get rowcount from Redshift (clone of Postrgesql 8)? import pg8000 connection_db = pg8000.connect( database=...) cursor = connection_db.cursor() cursor.execute("SELECT var_val FROM ods.etl_var_tbl WHERE var_nm = 'bucket'") return_value = cursor.fetchone()[0] rn = cursor.rowcount print("the number of rows affected ", rn) print(return_value)

I got the value from SELECT statement but rowcount = -1. Thank you

tlocke commented 3 years ago

Hi @dburtsev, I'm afraid Amazon Redshift isn't officially supported by pg8000. The reason is that pg8000 supports PostgreSQL, and as you say, Redshift was forked from PostgreSQL. IIRC rowcount wasn't supported in older versions of PostgreSQL, so probably that's why it's coming back with a -1.