discord.js - Imagine ❄d-I❄
discord.js - Imagine ❄16mo ago
12 replies
Zuk

Database connection

Hey I have a mysql database, I can connect to it and run CRUD actions.

But I feel like the setup is wrong.

I have this function:
export const db = mysql.createConnection({
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
});


and I call the db for running queries.
But that means I create a connection on any query, what would be the correct way to connection the bot on startup and have a live connection?
Was this page helpful?