[CONPY-120] Provide way to inspect defaults Created: 2020-10-05  Updated: 2022-01-24

Status: Open
Project: MariaDB Connector/Python
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Manjot Singh (Inactive) Assignee: Georg Richter
Resolution: Unresolved Votes: 0
Labels: None


 Description   

With the python connector, we can do conn.connect() or conn.connect(default_file=) to connect to the database. This will automatically (great feature!) read cnf files in the same precedence as command line tools.

The problem is, as developers we don't know what these are, only that a connection is made.

There should be an object conn.defaults() or conn.configuration_settings() etc that can be used to understand what files, sections and variables are being used to create a connection.

This should work prior to conn.connect() and after. i.e. it will show what it would use to connect if it tries to connect. After connection, it would show what it used to connect.



 Comments   
Comment by Sergei Golubchik [ 2021-07-19 ]

A simple way to make C/C to read the default files would be for C/Py to invoke mysql_real_connect() with an invalid protocol value (or some other invalid argument), it'll make mysql_real_connect to read default files and them immediately return an error. After that C/Py can examine MYSQL struct and return optioins in some pythonic way, like, a dict.

Comment by Georg Richter [ 2021-07-19 ]

Do we really need to inspect configuration values before establishing a connection? I doubt that someone wants to write a python application just to check content of configuration files.

Comment by Manjot Singh (Inactive) [ 2021-07-19 ]

I literally do, and need this for a tool I am working on. This can be done in other connectors, and our c connector.

Comment by Georg Richter [ 2021-07-19 ]

@manjot: Connector/C doesn't provide an api for retrieving the configuration values without connection.

Generated at Thu Feb 08 03:30:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.