luasql icon indicating copy to clipboard operation
luasql copied to clipboard

Add support for MySQL service file for connect()

Open mileib opened this issue 5 years ago • 1 comments

Unlike the PostgreSQL interface (which works fine), the MySQL interface does not seem to support a services file as there is no call to mysql_options(conn, MYSQL_READ_DEFAULT_GROUP, servicename); anywhere in the current ls_mysql.c code.

If I have MYSQL_HOME set in the environment and issue a connect with "service=foobar" when I invoke luasql, the connection information in the my.cnf file located in MYSQL_HOME for connection foobar should be parsed and used.

That is the only thing I should have to specify on the connection string and all the other required options will be pulled from the file under the foobar connection settings.

If I try this with the current code, it doesn't work and I receive

"Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"

If I hack up the connect function and use mysql_options() as described above, it works fine.

mileib avatar Apr 28 '20 20:04 mileib

Hi mileib

Could you share your code or add a pull request?

Regards, Tomás

tomasguisasola avatar Sep 08 '20 12:09 tomasguisasola