mysql.connectror works with openpyxl, but fails without

69 views
Skip to first unread message

Jarle Hammen Knudsen

unread,
Apr 21, 2022, 4:47:09 PM4/21/22
to openpyxl-users
The following following code fails, but if I add import openpyxl, it works! Why? What is going on under the hood with openpyxl?

The mysql user requiers SSL. DB is mariadb on Debian 10, client is on Debian 11 Connecting with the mysql command line client works.

######################
import mysql.connector

mydb = mysql.connector.connect(
    host='myhnost',
    user='medreg_add_script',
    password='mypass',
    database='mydb',
)
######################
Traceback (most recent call last):
  File "/home/jarle/prosjekt/medreg/test-db.py", line 5, in <module>
    mydb = mysql.connector.connect(
  File "/usr/local/lib/python3.9/dist-packages/mysql/connector/__init__.py", line 272, in connect
    return CMySQLConnection(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/mysql/connector/connection_cext.py", line 85, in __init__
    self.connect(**kwargs)
  File "/usr/local/lib/python3.9/dist-packages/mysql/connector/abstracts.py", line 1028, in connect
    self._open_connection()
  File "/usr/local/lib/python3.9/dist-packages/mysql/connector/connection_cext.py", line 241, in _open_connection
    raise errors.get_mysql_exception(msg=exc.msg, errno=exc.errno,
mysql.connector.errors.InterfaceError: 2026 (HY000): SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

Cheers,
Jarle

Charlie Clark

unread,
Apr 22, 2022, 3:39:02 AM4/22/22
to 'Jarle Hammen Knudsen' via openpyxl-users
On 21 Apr 2022, at 22:47, 'Jarle Hammen Knudsen' via openpyxl-users wrote:

> The following following code fails, but if I add import openpyxl, it works!
>
> Why? What is going on under the hood with openpyxl?
>
> The mysql user requiers SSL. DB is mariadb on Debian 10, client is on
>
> Debian 11 Connecting with the mysql command line client works.

This really has nothing to do with openpyxl.

Charlie

--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Sengelsweg 34
Düsseldorf
D- 40489
Tel: +49-203-3925-0390
Mobile: +49-178-782-6226

Jarle Hammen Knudsen

unread,
Apr 22, 2022, 5:47:41 AM4/22/22
to openpyxl-users
On Friday, 22 April 2022 at 09:39:02 UTC+2 charli...@clark-consulting.eu wrote:
On 21 Apr 2022, at 22:47, 'Jarle Hammen Knudsen' via openpyxl-users wrote:

> The following following code fails, but if I add import openpyxl, it works!
>
> Why? What is going on under the hood with openpyxl?
>
> The mysql user requiers SSL. DB is mariadb on Debian 10, client is on
>
> Debian 11 Connecting with the mysql command line client works.

This really has nothing to do with openpyxl.


But adding openpyxl changes the result, so yes it does!

Cheers,
Jarle
 

Charlie Clark

unread,
Apr 22, 2022, 11:49:51 AM4/22/22
to 'Jarle Hammen Knudsen' via openpyxl-users

On 22 Apr 2022, at 11:47, 'Jarle Hammen Knudsen' via openpyxl-users wrote:

But adding openpyxl changes the result, so yes it does!

There is nothing openpyxl itself that would make any difference so you're seeing correlation at most and asserting causation is a waste of time.

You do need to debug the connection. I do remember a problem with pgloader and mysql requiring SSL and I think this was fixed by changing a setting but the last time I connected from Python MySQL was using SQLAlchemy which handles the connection stuff.

Anyway, the MySQL driver list is where you need to take this discussion.

Jason Cobble

unread,
Apr 26, 2022, 12:43:14 AM4/26/22
to openpyx...@googlegroups.com
*

--
You received this message because you are subscribed to the Google Groups "openpyxl-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpyxl-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openpyxl-users/BC843198-146D-45F2-84A8-EEAE55C20AE0%40clark-consulting.eu.
Reply all
Reply to author
Forward
0 new messages