#mysql2 connection pool

4 messages · Page 1 of 1 (latest)

sharp ledge
#

How can I use the mysql2 package to build a pool object once when Nitro is initialized and allow it to be used in endpoints?

bold novaBOT
#

Hi @sharp ledge. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I do not have enough information to answer your question specifically about using mysql2 with Nitro. The provided knowledge sources don't contain direct information about using mysql2 or connection pooling with Nitro.

However, it's important to note that mysql libraries, including mysql2, may not be fully compatible with all Nitro deployment environments. According to the Incompatible libraries (https://nitro.unjs.io/deploy/workers#incompatible-libraries) documentation, mysql is listed as incompatible with edge workers.

For database connectivity in Nitro, the documentation suggests using the built-in database layer, which is currently experimental. This layer supports SQLite out of the box and can be configured for other databases. You can find more information about this in the SQL Database guide (https://nitro.unjs.io/guide/database).

If you specifically need to use mysql2, you might want to explore custom solutions or check if there are any updates to Nitro that support this use case. For the most up-to-date information, I recommend checking the official Nitro documentation or reaching out to the Nitro community for specific guidance on using mysql2 with connection pooling.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@sharp ledge Kapa.ai is still learning and improving, please let me know how I did by reacting below.