Missing or non-functional SSL parameter
old-adapdr opened this issue · comments
Ada commented
Not sure if this is a bug or a feature request so bear with me.
I'm trying to access a remote database which requires SSL (Which can be blank, don't ask me why.) with orator it errors out, but it works fine using pymysql directly.
Orator Code:
config = {
"mysql": {
"driver": "mysql",
"host": 'replication.example.com',
"database": 'some_db',
"user": 'some_user',
"password": 'some_password',
"prefix": "",
"ssl": {'ssl': {}},
}
}
db = DatabaseManager(config)
Model.set_connection_resolver(db)
Orator Error
Traceback (most recent call last):
File "/home/ap/Documents/playground/tester.py", line 4, in <module>
db.Branch.read()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 66, in __getattr__
query = cls.query()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 1922, in query
return cls().new_query()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 129, in __init__
self._boot_if_not_booted()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 156, in _boot_if_not_booted
klass._boot()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 174, in _boot
cls._boot_mixins()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 194, in _boot_mixins
if hasattr(mixin, method):
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 66, in __getattr__
query = cls.query()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 1922, in query
return cls().new_query()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 1891, in new_query
builder = self.new_query_without_scopes()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 1916, in new_query_without_scopes
builder = self.new_orm_builder(self._new_base_query_builder())
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 1943, in _new_base_query_builder
conn = self.get_connection()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 2886, in get_connection
return self.resolve_connection(self.__connection__)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/orm/model.py", line 2920, in resolve_connection
return cls.__resolver.connection(connection)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/database_manager.py", line 42, in connection
connection = self._make_connection(name)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/database_manager.py", line 133, in _make_connection
return self._factory.make(config, name)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/connectors/connection_factory.py", line 32, in make
return self._create_single_connection(config)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/connectors/connection_factory.py", line 35, in _create_single_connection
conn = self.create_connector(config).connect(config)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/connectors/connector.py", line 37, in connect
self._connection = self._do_connect(config)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/orator/connectors/mysql_connector.py", line 101, in _do_connect
return self.get_api().connect(**self.get_config(config))
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/pymysql/connections.py", line 325, in __init__
self.connect()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/pymysql/connections.py", line 599, in connect
self._request_authentication()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/pymysql/connections.py", line 861, in _request_authentication
auth_packet = self._read_packet()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/pymysql/connections.py", line 684, in _read_packet
packet.check_error()
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/home/ap/Documents/playground/venv/lib/python3.8/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'my_user'@'some_server' (using password: YES)")
config = {
"mysql": {
"driver": "mysql",
"host": 'replication.example.com',
"database": 'some_db',
"user": 'some_user',
"password": 'some_password',
"prefix": "",
"ssl": {'ssl': {}},
}
}
db = DatabaseManager(config)
Model.set_connection_resolver(db)
The equivalent using a pymysql connection.
pymysql.connect(
host='replication.example.com',
user='some_user',
password='some_password',
database='some_db',
charset="utf8mb4",
ssl={"ssl": {}},
cursorclass=DictCursor,
)
Ada commented
Must have been a local issue on my side. Works fine in fresh virtual environment. /shrug