"errorMessage": "'psycopg2.extensions.connection' object has no attribute 'cusor'
GNNotionlabs opened this issue · 4 comments
Hi all,
I have connected to AWS RDS Postgres with psycopg2-3.6 but can't use cusor or execute command.
Anyone resolve this issue?
START RequestId: 1932d209-b708-4adb-8690-ce77059c867e Version: $LATEST
'psycopg2.extensions.connection' object has no attribute 'cusor': AttributeError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 13, in lambda_handler
cur = conn.cusor()
AttributeError: 'psycopg2.extensions.connection' object has no attribute 'cusor'
- Python Runtime: 3.6
- psycopg2-3.6
Here is my code very simple
`import sys
import logging
import psycopg2
import psycopg2.extras
def lambda_handler(event, context):
conn=psycopg2.connect("dbname=*** host=*** port=5439 user=*** password=***")
#Connect and execute scripts
cur = conn.cusor()
cur.execute("TRUNCATE TABLE dwh_ods.rpt12_bcbs_payroll_report;")
conn.commit()
conn.close()
return "Executed!"`
i think psydopg2 for python3 has some error
I still can use it on Windows 10 or Ubuntu but when deploy to AWS Lambda, it's failed. So sad!
@GNNotionlabs uh I think you meant to type 'cursor' not 'cursor'... probably the cause
@GNNotionlabs uh I think you meant to type 'cursor' not 'cursor'... probably the cause
Very thank you, it's working :D