Patch to to use UNIX domain socket instead to TCP.

68 views
Skip to first unread message

Joe Smooze

unread,
Feb 6, 2023, 3:02:49 PM2/6/23
to weewx-development
For those of us that prefer domain sockets to TCP for mysql.

This just looks for a slash in 'host = ' in the [[MySQL]] stanza of weewx.conf and then uses mysql.sock instead of TCP to connect to the database.

Regards,
Joe


weewx-conf.patch
weewx-mysql.patch

Tom Keffer

unread,
Feb 20, 2023, 6:10:57 PM2/20/23
to Joe Smooze, weewx-development
Joe,

Have you actually tried this? The logic picks a socket if the name has a slash in it, but host IP addresses can also have a slash. E.g., https://acme.com

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/5eeaa553-9b04-499a-8efa-79f9303ca274n%40googlegroups.com.

Tom Keffer

unread,
Feb 20, 2023, 6:49:16 PM2/20/23
to Joe Smooze, weewx-development
With a little experimentation, it turns out you connect to a socket if you prefer with the present version of WeeWX. Use this in weewx.conf:

    [[MySQL]]
        # The host where the database is located
        host = ''
        unix_socket = /var/run/mysqld/mysqld.sock

Use an empty string for the hostname. Add an option "unix_socket" for the socket address.

This works because the driver passes on any unknown options, in this case, unix_socket, to the MySQL driver.

-tk

Joe Smooze

unread,
Feb 22, 2023, 4:02:15 PM2/22/23
to weewx-development
That's not a hostname. https://example.com is a URL. / is not an allowed character in a hostname.

Joe Smooze

unread,
Feb 22, 2023, 4:09:11 PM2/22/23
to weewx-development
Excellent. I didn't even try that.

Could you update the documentation and the examples in weewx.conf, please?

Regards,
Joe

Tom Keffer

unread,
Feb 22, 2023, 4:41:27 PM2/22/23
to Joe Smooze, weewx-development
Reply all
Reply to author
Forward
0 new messages