ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

Connect user and password const? #211

Open EdwinGH opened 1 year ago

EdwinGH commented 1 year ago

In my Arduino code I am defining: const char* mysql_user= "user"; Using const as best practice for defining strings this way (and to prevent compiler warnings like ISO C++ forbids converting a string constant to 'char*'). When calling conn.connect(mysql_server, 3306, mysql_user, mysql_password) I get a compiler error: error: invalid conversion from 'const char' to 'char'

I looked at the signature of connect: boolean MySQL_Connection::connect(IPAddress server, int port, char *user, char *password, char *db) And I wonder why user, password, and db are not defined as const char, as I do not see them changed anywhere. Any suggestions how to best solve this?

ChuckBell commented 1 year ago

Yep. Change it yourself on your PC. :) If it works and you’re happy with it, you are welcome to make a pill request and submit the change. Behold, the power of open source!

On Thu, May 18, 2023 at 13:08 EdwinGH @.***> wrote:

In my Arduino code I am defining: const char mysql_user= "user"; Using const as best practice for defining strings this way (and to prevent compiler warnings like ISO C++ forbids converting a string constant to 'char'). When calling conn.connect(mysql_server, 3306, mysql_user, mysql_password) I get a compiler error: error: invalid conversion from 'const char' to 'char'

I looked at the signature of connect: boolean MySQL_Connection::connect(IPAddress server, int port, char user, char password, char *db) And I wonder why user, password, and db are not defined as const char, as I do not see them changed anywhere. Any suggestions how to best solve this?

— Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYGU3A3XXEPZRHJZXNLXGZJSPANCNFSM6AAAAAAYGXAE2Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ChuckBell commented 1 year ago

Sorry, I didn’t fully answer your question. I made the original code to an LCD standard. Most board compilers understand char but at the time fewer would permit Cindy char and there are use cases for not using const.

On Thu, May 18, 2023 at 13:08 EdwinGH @.***> wrote:

In my Arduino code I am defining: const char mysql_user= "user"; Using const as best practice for defining strings this way (and to prevent compiler warnings like ISO C++ forbids converting a string constant to 'char'). When calling conn.connect(mysql_server, 3306, mysql_user, mysql_password) I get a compiler error: error: invalid conversion from 'const char' to 'char'

I looked at the signature of connect: boolean MySQL_Connection::connect(IPAddress server, int port, char user, char password, char *db) And I wonder why user, password, and db are not defined as const char, as I do not see them changed anywhere. Any suggestions how to best solve this?

— Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYGU3A3XXEPZRHJZXNLXGZJSPANCNFSM6AAAAAAYGXAE2Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

EdwinGH commented 1 year ago

I have made a fork, did the proposed changes, checked that it solves the issue, and submitted the pull request. First time I'm doing this (thanks for encouraging me!), so not sure what happens next. On my side things are working, so happy anyway!