-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add support for asyncpg driver. #218
Comments
How'd you go with this? We're looking at moving to cloud-sql-python connector, but are heavily dependant on asyncpg at the moment. From what I can gather from a quick gaze, is that we need to skip the custom # asyncpg.connection.connect:
async def connect(
dsn=None,
*,
# ... other kwargs ...
tls_proxy=None # NOTE: new_field
):
# ... gets passed into asyncpg.connect_utils._connect ...
# which calls _parse_connect_arguments:
def _parse_connect_arguments(
*,
# ... other kwargs ...
tls_proxy # NOTE: new_field
):
# ... gets passed into asyncpg.connect_utils._connect_addr ...
# which could look something like this:
async def __connect_addr(
params,
timeout,
retry,
addr,
loop,
config,
connection_class,
record_class,
params_input,
):
connected = _create_future(loop)
proto_factory = lambda: protocol.Protocol(
addr, connected, params, record_class, loop)
if isinstance(addr, str):
# UNIX socket
connector = loop.create_unix_connection(proto_factory, addr)
# NOTE: new_code
elif params.ssl and params.tls_proxy:
# passing ctx, to asyncio.events.create_connection,
# bypassing asyncpg's _create_ssl_connection
connector = loop.create_connection(
proto_factory, *addr, ssl=params.ssl
)
elif params.ssl:
connector = _create_ssl_connection(
proto_factory, *addr, loop=loop, ssl_context=params.ssl,
ssl_is_advisory=params.sslmode == SSLMode.prefer)
else:
connector = loop.create_connection(proto_factory, *addr) |
@sholmesy Thanks for the comment! I am currently working on a PR to update the asyncpg repository to allow for connections from the Cloud SQL Python Connector. The change looks very similar to what you have mentioned here, just working through some final tweaks before I put up the PR. Once the change is implemented within asyncpg, the update to this repository is pretty straightforward. Hopefully if all goes smoothly, asyncpg will be supported sometime in the following couple of weeks. I will link the issue here and follow up on this thread with any new updates or developments. Thanks for showing your interest in using the Python Connector and have an awesome day! Linked Issue: MagicStack/asyncpg/#906 |
Sounds good, let me know if you need a hand with anything. |
@sholmesy The PR has been merged upstream into asyncpg. A new release of asyncpg should be coming out in the next week or two that has the new changes reflected . I will finish up the required changes here in the python connector in the meantime so that support for asyncpg is ready upon the new release. |
Thanks, good news. |
Support PostgreSQL asyncpg async driver with connector.
The text was updated successfully, but these errors were encountered: