Last active
May 20, 2023 00:02
-
-
Save pmartinez8241/d00d95e35abac0b83aaefbb1135ff9f4 to your computer and use it in GitHub Desktop.
How to create, then use, a postgres REFCURSOR in postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
import json | |
def get_drives_and_media_type(): | |
results = [] | |
with psycopg2.connect("host=# dbname=entertainment_database user=# password=#") as conn: | |
with conn.cursor() as db_cursor: | |
db_cursor.callproc('GET_DRIVES_AND_MEDIA_TYPES',['something']) | |
with conn.cursor('something') as cursor2: | |
for x in cursor2: | |
results.append({'table_name':x[0],'id':x[1],'name':x[2],'storage_type':x[3]}) | |
return results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment