Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion website/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ try {
} catch (err) {
console.log(err);
}

// Close the connection
await connection.end();
```

</TabItem>
Expand Down Expand Up @@ -138,6 +141,9 @@ connection.query(
console.log(results);
}
);

// Close the connection
connection.end();
```

</TabItem>
Expand All @@ -161,9 +167,11 @@ MySQL2 provides `execute` helper which will prepare and query the statement. You
```js
import mysql from 'mysql2/promise';

let connection;

try {
// create the connection to database
const connection = await mysql.createConnection({
connection = await mysql.createConnection({
host: 'localhost',
user: 'root',
database: 'test',
Expand All @@ -179,6 +187,8 @@ try {
console.log(fields); // fields contains extra meta data about results, if available
} catch (err) {
console.log(err);
} finally {
connection.end()
}
```

Expand All @@ -204,6 +214,9 @@ connection.execute(
console.log(fields); // fields contains extra meta data about results, if available
}
);

// Close the connection
connection.end();
```

</TabItem>
Expand Down