Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added close connections in quickstart. #2725

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
Loading