Repository navigation
Add docs for SQL Alchemy ORM support - #1237
Conversation
…hemy and add note on wrapper_plugins
|
|
||
| | Driver | Database Dialect | | ||
| |-------------------|------------------| | ||
| | `aws_wrapper_mysqlconnector` | `mysql` | |
There was a problem hiding this comment.
Curious on this "database dialect" - is that from our wrapper or sql alchemy? if it's our wrapper should we not support aurora-mysql and the other mysql database dialects too?
There was a problem hiding this comment.
I copied this table from the other documentation and adapted it to fit the URL information defined in pyproject.toml:
[tool.poetry.plugins."sqlalchemy.dialects"]
"mysql.aws_wrapper_mysqlconnector" = "aws_advanced_python_wrapper.sqlalchemy.mysql_orm_dialect:SqlAlchemyOrmMysqlDialect"
This is supposed to help the user figure out what the put in their create_engine URL:
create_engine("**mysql+aws_wrapper_mysqlconnector**://your_username:your_password@your-cluster-endpoint.cluster-xyz.us-east-1.rds.amazonaws.com:your_port/your_database_name?connect_timeout=10&wrapper_plugins=aurora_connection_tracker%2Cfailover_v2")
I don't believe we need to explicitly add the aurora-mysql and other mysql database dialects here, but I'm also not 100% sure about this. Maybe worth asking @faviansamatha about this?
|
|
||
| The Read/Write Splitting Plugin is not supported for SQLAlchemy, since session binds already implement this functionality. | ||
|
|
||
| See the [official SQLAlchemy documentation on the Session API](https://docs.sqlalchemy.org/en/20/orm/session_api.html) for more information on session binds. |
There was a problem hiding this comment.
I would love to see this maybe structured a different way or with some additional plugins that ARE supported. You say that there are many other plugins and then only list one so I would suggest either
- add to line 34 that failover is the most relevant and then keep the section as is
- list iam as another plugin that is helpful after failover
I would also like rw splitting to be under a header of something like "not supported" It's confusing that it is positioned the same way as failover which is supported. Adding a not supported section would also give you space to mention that lack of pg support again
There was a problem hiding this comment.
We could consider reworking this into a plugin compatibility section, and create a table indicating which plugins are supported and which are not (rw splitting and srw)
Co-authored-by: Karen <64801825+karenc-bq@users.noreply.github.com>
…o failover 2 docs
|
|
||
| | Plugin name | Plugin Code | Supported? | | ||
| |-------------------------------------------------------------------------------------------------|-------------------------------------------|-----| | ||
| | [Failover Plugin](./using-plugins/UsingTheFailoverPlugin.md) | `failover` | Yes | |
There was a problem hiding this comment.
Nit: but can you use checks and crosses for this table? It makes it more readable and the difference distinguishable
<span style="color:red;font-size:20px">✗</span>
<span style="color:yellow;font-size:15px">✓</span>
|
|
||
| | Driver | Database Dialect | | ||
| |-------------------|------------------| | ||
| | `aws_wrapper_mysqlconnector` | `mysql` | |
There was a problem hiding this comment.
Let's just add a comment underneath that says
Ensure what is passed to create_engine always starts with "mysql+aws_wrapper_mysqlconnector:.... Further setting of the database dialect within the wrapper can be done with the wrapper_dialect parameter, for more details see: Database Dialects.
| |-------------------|------------------| | ||
| | `aws_wrapper_mysqlconnector` | `mysql` | | ||
|
|
||
| Ensure what is passed to create_engine always starts with `"mysql+aws_wrapper_mysqlconnector:..."`. Further setting of the database dialect within the wrapper can be done with the wrapper_dialect parameter, for more details see: [Database Dialects](https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-wrapper/DatabaseDialects.md). |
There was a problem hiding this comment.
| Ensure what is passed to create_engine always starts with `"mysql+aws_wrapper_mysqlconnector:..."`. Further setting of the database dialect within the wrapper can be done with the wrapper_dialect parameter, for more details see: [Database Dialects](https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-wrapper/DatabaseDialects.md). | |
| Ensure what is passed to create_engine always starts with `"mysql+aws_wrapper_mysqlconnector:..."`. Further setting of the database dialect within the wrapper can be done with the 1wrapper_dialect1 parameter, for more details see: [Database Dialects](https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-wrapper/DatabaseDialects.md). |
There was a problem hiding this comment.
Were these meant to be graves instead of 1s surrounding wrapper_dialect?
|
|
||
| #### Handling Failover Events | ||
|
|
||
| During a failover event, the driver will throw a `DBAPIError` exception after successfully connecting to a new instance. Your application should catch this exception, check which type of failover error occurred, and retry the failed query: |
There was a problem hiding this comment.
Can we add a hyperlink to the failover error, and link it to the failover errors documentation
| > SQLAlchemy reserves the `plugins` connection parameter for its own engine, pool, and dialect event listeners. | ||
| > When using SQLAlchemy, enable AWS Advanced Python Wrapper plugins (such as the Aurora Initial Connection Strategy plugin) via `wrapper_plugins`. Otherwise, use `plugins` as usual. | ||
|
|
||
| For a complete list of available plugins, see the [List of Available Plugins](./UsingThePythonWrapper.md#list-of-available-plugins) in the main driver documentation. |
There was a problem hiding this comment.
Can we point this to the Plugin Compatibility section below instead of list of available plugins
Co-authored-by: aaron-congo <aaron.congo@improving.com> Co-authored-by: Karen <64801825+karenc-bq@users.noreply.github.com>
Description
This PR adds documentation for SQL Alchemy ORM support.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.