Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PyMySQL #752

Open
1 of 2 tasks
LucasPedrosoTI opened this issue Nov 28, 2024 · 1 comment
Open
1 of 2 tasks

Support for PyMySQL #752

LucasPedrosoTI opened this issue Nov 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@LucasPedrosoTI
Copy link

Describe the feature

Support the usage of the pymysql connector

Use Case

The project I'm working on uses pymysql, I tried to pass the Connect class to the AwsWrapperConnection, however, it's failing because it's casting the port argument to a string, even though I'm passing an int.

Code that's turning the port into a string:

def prepare_connect_info(self, host_info: HostInfo, props: Properties) -> Properties:
        prop_copy: Properties = Properties(props.copy())

        prop_copy["host"] = host_info.host

        if host_info.is_port_specified():
            prop_copy["port"] = str(host_info.port)

        PropertiesUtils.remove_wrapper_props(prop_copy)
        return prop_copy

pymysql code enforcing the int type:
connections.py

// ...
self.port = port or 3306
        if type(self.port) is not int:
            raise ValueError("port should be of type int")
// ...

I wonder if it's possible to remove that cast to string or adapt somehow to support pymysql. I'm not sure if that's all it's going to take, though.

Proposed Solution

Remove the cast to string for the port

if host_info.is_port_specified():
            prop_copy["port"] = host_info.port

or a condition for the pymysql library

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

The AWS Advanced Python Wrapper version used

1.1.1

Python version used

3.12

Operating System and version

Ubuntu 22.04

@LucasPedrosoTI LucasPedrosoTI added the enhancement New feature or request label Nov 28, 2024
@LucasPedrosoTI
Copy link
Author

I patched the initfor the Connection to enforce the int type for the port. However, looks like it isn't the only issue. Now, I'm getting an error related to the in_transaction property:

File "/venv/lib/python3.12/site-packages/aws_advanced_python_wrapper/mysql_driver_dialect.py", line 124, in is_in_transaction
    raise UnsupportedOperationError(
aws_advanced_python_wrapper.UnsupportedOperationError: [DriverDialect] target driver 'MySQL Connector Python' dialect doesn't support 'in_transaction'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant