I am trying to use sqlacodegen
on my database
.
sqlacodegen mysql://root:mypassword@localhost/database_name
However, I keep receiving this error:
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
In my flask
application however, I access this very same database
with no issues.
The above file doesn't exist on my system so I went to /etc/mysql/my.cnf
and changed the line:
socket = /var/run/mysqld/mysqld.sock
to
socket = /opt/lampp/var/mysql/mysql.sock
Not entirely sure if this was the correct thing to do.. however even after this change, the systems seems to still be trying to run from the original location.
you can just create a symbolic link at
/var/run/mysqld/mysqld.sock
to the lampp's mysql sock.restart lampp's mysql