Socket
Socket
Sign inDemoInstall

@types/mysql

Package Overview
Dependencies
2
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/mysql

TypeScript definitions for mysql


Version published
Weekly downloads
1.1M
decreased by-13.08%
Maintainers
1
Install size
2.01 MB
Created
Weekly downloads
 

Package description

What is @types/mysql?

The @types/mysql package provides TypeScript type definitions for the mysql package, enabling better development experience with type checking and IntelliSense in TypeScript projects. It does not add any new functionality to mysql itself but allows developers to use mysql in TypeScript applications more effectively.

What are @types/mysql's main functionalities?

Connecting to a MySQL database

This code demonstrates how to connect to a MySQL database using the mysql package with TypeScript types provided by @types/mysql. It includes type checking for the connection options.

import * as mysql from 'mysql';
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'yourusername',
  password: 'yourpassword',
  database: 'mydb'
});
connection.connect(err => {
  if (err) throw err;
  console.log('Connected!');
});

Performing a query

This example shows how to perform a basic SQL query to select all records from the 'users' table. The results are logged to the console. The @types/mysql package ensures that the function parameters and return types are correctly typed.

connection.query('SELECT * FROM users', (err, results) => {
  if (err) throw err;
  console.log(results);
});

Closing the connection

This snippet illustrates how to close the database connection properly. It uses the end method provided by the mysql package, with type safety ensured by @types/mysql.

connection.end(err => {
  if (err) return console.log('error:' + err.message);
  console.log('Close the database connection.');
});

Other packages similar to @types/mysql

Readme

Source

Installation

npm install --save @types/mysql

Summary

This package contains type definitions for mysql (https://github.com/mysqljs/mysql).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mysql.

Additional Details

  • Last updated: Mon, 11 Mar 2024 23:35:33 GMT
  • Dependencies: @types/node

Credits

These definitions were written by William Johnston, Krittanan Pingclasai, James Munro, and Sanders DeNardi.

FAQs

Last updated on 11 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc