Reputation: 341
Code works fine in virtual environment and I am deploying code correctly with all the dependencies but when my code tries to execute an SQL raw query using SQLAlchemy, I get this
{
"stackTrace": [
[
"/var/task/aws_handler.py",
13,
"twilio_handler",
"sms_bot.handle_communication(message_body, recipient)"
],
[
"/var/task/sms_bot.py",
86,
"handle_communication",
"is_authenticated, user_id = self.authenticate_user(recipient)"
],
[
"/var/task/sms_bot.py",
38,
"authenticate_user",
"result = execute_query(query)"
],
[
"/var/task/db_handler.py",
28,
"execute_query",
"connection = get_db_connection()"
],
[
"/var/task/db_handler.py",
19,
"get_db_connection",
"return get_sqlalchemy_engine().connect()"
],
[
"/var/task/db_handler.py",
11,
"get_sqlalchemy_engine",
"return create_engine(SQLALCHEMY_DATABASE_URI)"
],
[
"/var/task/sqlalchemy/engine/__init__.py",
386,
"create_engine",
"return strategy.create(*args, **kwargs)"
],
[
"/var/task/sqlalchemy/engine/strategies.py",
75,
"create",
"dbapi = dialect_cls.dbapi(**dbapi_args)"
],
[
"/var/task/sqlalchemy/dialects/mysql/mysqldb.py",
92,
"dbapi",
"return __import__('MySQLdb')"
],
[
"/var/task/MySQLdb/__init__.py",
19,
"<module>",
"import _mysql"
]
],
"errorType": "ImportError",
"errorMessage":
"libmysqlclient.so.20: cannot open shared object file: No such
file or directory"}
NOTE: SQL_URI is correct and working locally
Upvotes: 1
Views: 2082
Reputation: 341
I found the solution, installed
libmysqlclient-dev
on my computer and copied
libmysqlclient.so.20
from
/usr/lib/x86_64-linux-gnu/
to my aws deployment package, changed the permissions to 777, compressed all files and uploaded to aws. It worked.
Upvotes: 1