Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[question] - How to get write operation details back#133

Unanswered
andormarkus asked this question inQ&A
Discussion options

Hi All,

When I run a INSERT / DELETE / COPY operation in my IDE I get back the number of row affected. (see picture below)
Screenshot 2022-09-26 at 12 15 07

How can I retrieve the same information with this driver as well?

Thanks,
Andor

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Hey@andormarkus , you should be able to retrieve this information,2515, in the example you provided, usingcursor.fetchone() method following executing the copy command likecursor.execute("COPY ...") . For instructions on how to get and use a cursor object for the current connection, please see ourAPI docs orconnection tutorials.

You must be logged in to vote
1 reply
@andormarkus
Comment options

Hi@Brooke-white

I tried to execute the following command and I got the following error.

sql="""COPY "stg"."dim_wfm"FROM 's3://bucket'IAM_ROLE '<arn>'CSV DATEFORMAT AS 'YYYY-MM-DD HH:MI:SS'TIMEFORMAT AS 'YYYY-MM-DD HH:MI:SS'IGNOREHEADER 1;"""redshift=helper.RedshiftHandler(secret_name=args.RedshiftSecret).connect()redshift.cursor.execute(sql)resp=redshift.cursor.fetchone()print(resp)
2022-09-27 20:09:23 INFO     Getting Connection Info2022-09-27 20:09:23 INFO     Secret is: REDSHIFT_SECRET2022-09-27 20:09:23 INFO     Found credentials from IAM Role: SSMInstanceProfile2022-09-27 20:09:23 INFO     Connecting to Redshift: redshift.amazonaws.com2022-09-27 20:09:23 INFO     Successfully Connected to ClusterTraceback (most recent call last):  File"/home/ec2-user/.virtualenvs/lib/python3.9/site-packages/redshift_connector/cursor.py", line 487,in __next__returnself._cached_rows.popleft()IndexError: pop from an empty dequeDuring handling of the above exception, another exception occurred:Traceback (most recent call last):  File"/tmp/pycharm_project_230/glue_jobs/etl/extract_test.py", line 48,in<module>    resp =redshift.cursor.fetchone()  File"/home/ec2-user/.virtualenvs/lib/python3.9/site-packages/redshift_connector/cursor.py", line 402,in fetchonereturn next(self)  File"/home/ec2-user/.virtualenvs/lib/python3.9/site-packages/redshift_connector/cursor.py", line 492,in __next__    raise ProgrammingError("no result set")redshift_connector.error.ProgrammingError: no resultsetProcess finished withexit code 1
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@andormarkus@Brooke-white

[8]ページ先頭

©2009-2025 Movatter.jp