https://github.com/t99/mysql-toolkit-js
My personal toolkit of functions and functionality for working with MySQL servers in TypeScript.
https://github.com/t99/mysql-toolkit-js
database mysql sql toolkit typescript
Last synced: about 2 months ago
JSON representation
My personal toolkit of functions and functionality for working with MySQL servers in TypeScript.
- Host: GitHub
- URL: https://github.com/t99/mysql-toolkit-js
- Owner: T99
- License: gpl-3.0
- Created: 2021-12-09T16:12:48.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-23T18:35:07.000Z (over 3 years ago)
- Last Synced: 2024-05-01T19:08:20.477Z (about 2 years ago)
- Topics: database, mysql, sql, toolkit, typescript
- Language: TypeScript
- Homepage:
- Size: 90.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# MySQL Toolkit
My personal toolkit of functions and functionality for working with MySQL servers in TypeScript.
### [Find @t99/mysql-toolkit on NPM.](https://www.npmjs.com/package/@t99/mysql-toolkit)
## Table of Contents
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Documentation](#documentation)
- [License](#license)
## Installation
Install from NPM with
```
$ npm install --save @t99/mysql-toolkit
```
## Basic Usage
The most common usage of this library is in using connection pools. Connection
pools are utilities for automatically distributing (and re-using) connections to
a given database server.
```typescript
import { DatabaseConnectionPool } from "@t99/mysql-toolkit";
const pool: DatabaseConnectionPool = new DatabaseConnectionPool({
host: "my.database.com",
user: "username",
password: "hunter1",
database: "plaintext_passwords",
});
```
This is a thin wrapper over the popular NPM library [`mysql`](https://www.npmjs.com/package/mysql).
You might even notice that the config object being passed to the constructor
above matches that which is expected to the constructor of the `mysql` library's
`Connection` object.
Now that we have this connection established, we can use it to query the
database that we've connected to:
```typescript
import { MySQLQueryResults } from "@t99/mysql-toolkit";
const queryResult: MySQLQueryResults = await pool.query(
"SELECT * FROM passwords"
);
```
## Documentation
See the [wiki](https://github.com/T99/mysql-toolkit-js/wiki) for full documentation.
## License
@t99/mysql-toolkit is made available under the GNU General Public License v3.
Copyright (C) 2022 Trevor Sears