1

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

3
  • try uninstall and re-install mysql python : pip uninstall mysql-python pip install mysql-python Check this link : stackoverflow.com/questions/34348752/… Commented Oct 26, 2016 at 13:42
  • 1
    Is libmysqlclient.so.20 inside your deployment package? Commented Oct 26, 2016 at 13:46
  • No it's not in my deployment package. How can I include it? Commented Oct 26, 2016 at 14:43

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.