PHPackages                             nemo64/dbal-rds-data - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. nemo64/dbal-rds-data

ActiveLibrary[Database &amp; ORM](/categories/database)

nemo64/dbal-rds-data
====================

rds-data driver for doctrine dbal

v1.3.2(5y ago)2713.2k2[3 issues](https://github.com/Nemo64/dbal-rds-data/issues)[1 PRs](https://github.com/Nemo64/dbal-rds-data/pulls)MITPHPPHP ~7.2||~8.0

Since Feb 29Pushed 4y ago4 watchersCompare

[ Source](https://github.com/Nemo64/dbal-rds-data)[ Packagist](https://packagist.org/packages/nemo64/dbal-rds-data)[ RSS](/packages/nemo64-dbal-rds-data/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (11)Used By (0)

[![Packagist Version](https://camo.githubusercontent.com/be9bc42972b957e04f22f05a88c513851f43faa5594dc547277582a8bad8e738/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4e656d6f36342f6462616c2d7264732d64617461)](https://packagist.org/packages/nemo64/dbal-rds-data)[![GitHub Workflow Status](https://camo.githubusercontent.com/88433bafa9ec6e55b9d37a279f815ba6116cf4c66cfe430bfbcc45f468736d1d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f4e656d6f36342f6462616c2d7264732d646174612f546573743f6c6162656c3d7465737473)](https://github.com/Nemo64/dbal-rds-data/actions?query=workflow%3ATest)[![Packagist License](https://camo.githubusercontent.com/887f16b66bec0b7744147018c566b4dcab2f105bcd08ce6f0a30feeee54548de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f4e656d6f36342f6462616c2d7264732d64617461)](https://github.com/Nemo64/dbal-rds-data/blob/master/LICENSE)[![Packagist Downloads](https://camo.githubusercontent.com/c40c5a2bbd59653b566edb16e03d080608571cc90ade60c377e44ff253d12e1c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f4e656d6f36342f6462616c2d7264732d64617461)](https://packagist.org/packages/nemo64/dbal-rds-data)

doctrine driver for the Aurora Serverless rds data api
======================================================

[](#doctrine-driver-for-the-aurora-serverless-rds-data-api)

This is a driver to use the aws [rds-data](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) api on projects that are using [dbal](https://www.doctrine-project.org/projects/doctrine-dbal/en/2.10/index.html) for their database access.

It emulates a MySQL connection including transactions. However: the driver does never establish a persistent connection.

This is experimental. I implemented it in a symfony project with the doctrine orm and with this driver it worked fine. I tested the schema tools, migrations and transactions.

At this moment, I wouldn't recommend using the rds-data api at all because of it's 1000 request per second limitation that they secretly added at the end of 2020. It is listed as "Data API requests per second" in your service quota list but not in the documentation.

Why would you use it?
---------------------

[](#why-would-you-use-it)

- The data api makes it possible to use a database in an aws hosting environment without the need for VPC's which add complexity and cost money if you need internet access though NAT Gateways.
- Your application does not need the database password in plain text. You just need access to the aws api which can be managed a lot better. (there are other ways to achieve the same but still, it is really easy with the data api)
- There might be a performance benefit due to not needing to establish a direct database connection and automatic pool management.

Why wouldn't you use it?
------------------------

[](#why-wouldnt-you-use-it)

- This implementation hasn't been battle tested for 20 years. Have a look into the [Implementation Details](#implementation-details) section and see if you are comfortable with them.
- Performance while running many small queries is probably the biggest issue. The rds data api has (as of writing this) a not well documented limit of 1000 queries per second per account. If you have ever worked with the doctrine orm, then you know that that's not a lot, especially if you run unoptimized background jobs. The aws sdk will retry queries, which just means that everything will become slow.
- The [rds-data](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) api has size restrictions in the [ExecuteStatement](https://docs.aws.amazon.com/rdsdataservice/latest/APIReference/API_ExecuteStatement.html) call which might become a problem when your application grows although they don't seem to be enabled at this moment.
- The [rds-data](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) api is [not available everywhere](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html#data-api.regions). This limitation is slowly getting lifted though.
- The [rds-data](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) api has some inherit limitations base on the fact that it is mostly stateless. The biggest problem is that you can't set (session) variables. This also means you can't [setTransactionIsolation](https://www.doctrine-project.org/projects/doctrine-dbal/en/2.10/reference/transactions.html) levels although that is an optional feature in dbal anyways. You can still use normal locking in transactions though.
- The [rds-data](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) api is only available with [Aurora Serverless](https://aws.amazon.com/de/rds/aurora/serverless/) and this library also limits you to MySQL mode. If you plan on using other databases then you can't use the rds-data api and this library (yet). Here are alternatives you might want to consider:
    - Aurora Serverless in Postgres mode (although this can probably very easily be added here, I'm open to pull requests)
    - Aurora Classic to get an [SLA](https://aws.amazon.com/de/rds/aurora/sla/) or to benefit from reserved instance pricing on predictable workloads
    - Aurora Global for better availability and all the benefits of Aurora Classic
    - or even normal RDS to save money or use engines that are not emulated by Aurora

How to use it
-------------

[](#how-to-use-it)

First you must store your database credentials as [a secret](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html#data-api.secrets) including the username. Then make sure to correctly configure [access to your database](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html#data-api.access) to use the secret and the database. If you create a iam user then there is a "AmazonRDSDataFullAccess" policy that can be used directly.

If you use dbal directly than this is the way:

```
