使用Sqlachemy与AWS Lambda Python功能连接到Postgres数据库时遇到问题(Chalice框架)

时间:2016-12-17 13:37:14

标签: python postgresql amazon-web-services lambda aws-lambda

我尝试使用aws chalice通过sqlalchemy从aws lambda函数连接到Postgres数据库。根据我的阅读,psycopg2是使用sqlalchemy建立连接所必需的。根据其他stackoverflow问题的建议,我在https://github.com/jkehler/awslambda-psycopg2使用psycopg2库但是,我在连接数据库时遇到问题。 lambda函数的错误如下所示。任何人都可以帮助我理解我所缺少的东西吗?

{
    "errorMessage": "/var/task/psycopg2/_psycopg.so: invalid ELF header", 
    "errorType": "ImportError", 
    "stackTrace": [
        [
            "/var/task/chalice/app.py", 
            258, 
            "__call__", 
            "response = view_function(*function_args)"
        ], 
        [
            "/var/task/app.py", 
            18, 
            "authenticateUser", 
            "(connection, metadata) = connect(DATABASE[\"username\"], DATABASE[\"password\"], DATABASE[\"database\"], DATABASE[\"host\"], DATABASE[\"port\"])"
        ], 
        [
            "/var/task/app.py", 
            32, 
            "connect", 
            "con = sqlalchemy.create_engine(url, client_encoding='utf8')"
        ], 
        [
            "/var/task/sqlalchemy/engine/__init__.py", 
            387, 
            "create_engine", 
            "return strategy.create(*args, **kwargs)"
        ], 
        [
            "/var/task/sqlalchemy/engine/strategies.py", 
            80, 
            "create", 
            "dbapi = dialect_cls.dbapi(**dbapi_args)"
        ], 
        [
            "/var/task/sqlalchemy/dialects/postgresql/psycopg2.py", 
            554, 
            "dbapi", 
            "import psycopg2"
        ], 
        [
            "/var/task/psycopg2/__init__.py", 
            50, 
            "<module>", 
            "from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID"
        ]
    ]
}

0 个答案:

没有答案