# mysql
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Linux Build][travis-image]][travis-url]
[![Windows Build][appveyor-image]][appveyor-url]
[![Test Coverage][coveralls-image]][coveralls-url]
## Table of Contents
- [Install](#install)
- [Introduction](#introduction)
- [Contributors](#contributors)
- [Sponsors](#sponsors)
- [Community](#community)
- [Establishing connections](#establishing-connections)
- [Connection options](#connection-options)
- [SSL options](#ssl-options)
- [Terminating connections](#terminating-connections)
- [Pooling connections](#pooling-connections)
- [Pool options](#pool-options)
- [Pool events](#pool-events)
- [Closing all the connections in a pool](#closing-all-the-connections-in-a-pool)
- [PoolCluster](#poolcluster)
- [PoolCluster options](#poolcluster-options)
- [Switching users and altering connection state](#switching-users-and-altering-connection-state)
- [Server disconnects](#server-disconnects)
- [Performing queries](#performing-queries)
- [Escaping query values](#escaping-query-values)
- [Escaping query identifiers](#escaping-query-identifiers)
- [Preparing Queries](#preparing-queries)
- [Custom format](#custom-format)
- [Getting the id of an inserted row](#getting-the-id-of-an-inserted-row)
- [Getting the number of affected rows](#getting-the-number-of-affected-rows)
- [Getting the number of changed rows](#getting-the-number-of-changed-rows)
- [Getting the connection ID](#getting-the-connection-id)
- [Executing queries in parallel](#executing-queries-in-parallel)
- [Streaming query rows](#streaming-query-rows)
- [Piping results with Streams](#piping-results-with-streams)
- [Multiple statement queries](#multiple-statement-queries)
- [Stored procedures](#stored-procedures)
- [Joins with overlapping column names](#joins-with-overlapping-column-names)
- [Transactions](#transactions)
- [Ping](#ping)
- [Timeouts](#timeouts)
- [Error handling](#error-handling)
- [Exception Safety](#exception-safety)
- [Type casting](#type-casting)
- [Connection Flags](#connection-flags)
- [Debugging and reporting problems](#debugging-and-reporting-problems)
- [Security issues](#security-issues)
- [Contributing](#contributing)
- [Running tests](#running-tests)
- [Todo](#todo)
## Install
This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/).
Before installing, [download and install Node.js](https://nodejs.org/en/download/).
Node.js 0.6 or higher is required.
Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
```sh
$ npm install mysql
```
For information about the previous 0.9.x releases, visit the [v0.9 branch][].
Sometimes I may also ask you to install the latest version from Github to check
if a bugfix is working. In this case, please do:
```sh
$ npm install mysqljs/mysql
```
[v0.9 branch]: https://github.com/mysqljs/mysql/tree/v0.9
## Introduction
This is a node.js driver for mysql. It is written in JavaScript, does not
require compiling, and is 100% MIT licensed.
Here is an example on how to use it:
```js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret',
database : 'my_db'
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
connection.end();
```
From this example, you can learn the following:
* Every method you invoke on a connection is queued and executed in sequence.
* Closing the connection is done using `end()` which makes sure all remaining
queries are executed before sending a quit packet to the mysql server.
## Contributors
Thanks goes to the people who have contributed code to this module, see the
[GitHub Contributors page][].
[GitHub Contributors page]: https://github.com/mysqljs/mysql/graphs/contributors
Additionally I'd like to thank the following people:
* [Andrey Hristov][] (Oracle) - for helping me with protocol questions.
* [Ulf Wendel][] (Oracle) - for helping me with protocol questions.
[Ulf Wendel]: http://blog.ulf-wendel.de/
[Andrey Hristov]: http://andrey.hristov.com/
## Sponsors
The following companies have supported this project financially, allowing me to
spend more time on it (ordered by time of contribution):
* [Transloadit](http://transloadit.com) (my startup, we do file uploading &
video encoding as a service, check it out)
* [Joyent](http://www.joyent.com/)
* [pinkbike.com](http://pinkbike.com/)
* [Holiday Extras](http://www.holidayextras.co.uk/) (they are [hiring](http://join.holidayextras.co.uk/))
* [Newscope](http://newscope.com/) (they are [hiring](https://newscope.com/unternehmen/jobs/))
## Community
If you'd like to discuss this module, or ask questions about it, please use one
of the following:
* **Mailing list**: https://groups.google.com/forum/#!forum/node-mysql
* **IRC Channel**: #node.js (on freenode.net, I pay attention to any message
including the term `mysql`)
## Establishing connections
The recommended way to establish a connection is this:
```js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
```
However, a connection can also be implicitly established by invoking a query:
```js
var mysql = require('mysql');
var connection = mysql.createConnection(...);
connection.query('SELECT 1', function (error, results, fields) {
if (error) throw error;
// connected!
});
```
Depending on how you like to handle your errors, either method may be
appropriate. Any type of connection error (handshake or network) is considered
a fatal error, see the [Error Handling](#error-handling) section for more
information.
## Connection options
When establishing a connection, you can set the following options:
* `host`: The hostname of the database you are connecting to. (Default:
`localhost`)
* `port`: The port number to connect to. (Default: `3306`)
* `localAddress`: The source IP address to use for TCP connection. (Optional)
* `socketPath`: The path to a unix domain socket to connect to. When used `host`
and `port` are ignored.
* `user`: The MySQL user to authenticate as.
* `password`: The password of that MySQL user.
* `database`: Name of the database to use for this connection (Optional).
* `charset`: The charset for the connection. This is called "collation" in the SQL-level
of MySQL (like `utf8_general_ci`). If a SQL-level charset is specified (like `utf8mb4`)
then the default collation for that charset is used. (Default: `'UTF8_GENERAL_CI'`)
* `timezone`: The timezone configured on the MySQL server. This is used to type cast server date/time values to JavaScript `Date` object and vice versa. This can be `'local'`, `'Z'`, or an offset in the form `+HH:MM` or `-HH:MM`. (Default: `'local'`)
* `connectTimeout`: The milliseconds before a timeout occurs during the initial connection
to the MySQL server. (Default: `10000`)
* `stringifyObjects`: Stringify objects instead of converting to values. See
issue [#501](https://github.com/mysqljs/mysql/issues/501). (Default: `false`)
* `insecureAuth`: Allow connecting to MySQL instances that ask for the old
(insecure) authentication method. (Default: `false`)
* `typeCast`: Determines if column values should be converted to native
JavaScript types. (Default: `true`)
* `queryFormat`: A custom query format function. See [Custom format](#custom-format).
* `supportBigNumbers`: When dealing with big numbers (BIGINT and DECIMAL columns) in the database,
you should e
懂球吗——基于Vue,Express,MongoDB,爬虫实现的足球论坛数据系统.zip
需积分: 0 33 浏览量
更新于2023-08-03
收藏 7.15MB ZIP 举报
这是一个基于Web技术构建的足球论坛数据系统,涵盖了前端、后端和数据库等多个层面的技术栈。以下将详细解析这个项目的组成部分及其涉及的知识点。
项目名称中的“Vue”指的是Vue.js,一个流行的前端JavaScript框架,用于构建用户界面。Vue.js以其易学易用、灵活可扩展的特点深受开发者喜爱。在这个项目中,Vue.js被用来创建动态的、交互性强的用户界面,处理用户输入,展示数据,并与服务器进行通信。
“Express”是Node.js的一个Web应用框架,简化了构建RESTful API的过程。在本项目中,Express作为后端服务器,负责接收前端发送的HTTP请求,处理业务逻辑,与数据库交互,然后返回相应的数据。开发者可以使用路由、中间件和模板引擎等功能来构建高效的服务端应用程序。
“MongoDB”是一种分布式文档型数据库,采用NoSQL的数据模型,适合处理大量非结构化数据。在这个足球论坛数据系统中,MongoDB用于存储论坛的各类数据,如用户信息、帖子、评论等。它的灵活性和高性能使其成为现代Web应用的理想选择。
“爬虫”是该项目的一个重要部分,它可能被用来自动抓取足球论坛上的相关信息,如比赛结果、球员数据等。爬虫技术基于Python等语言实现,通过模拟浏览器行为,遍历和提取网页数据,为论坛提供实时更新的信息源。
文件名称“Vue-football-pro-backend-master”表明这是项目后端代码的主分支,可能是GitHub仓库的克隆。在这个目录下,你可以找到Express的配置文件、路由定义、模型(models)、控制器(controllers)以及可能的中间件和配置文件,这些都是构建后端服务的关键部分。
总体来说,这个项目涉及到的知识点包括:
1. 前端开发:Vue.js框架的应用,包括组件化开发、状态管理(可能使用Vuex)、路由(Vue Router)等。
2. 后端开发:Node.js环境下的Express框架,用于构建RESTful API,处理HTTP请求和响应。
3. 数据库管理:MongoDB的使用,包括数据模型设计、CRUD操作、查询优化等。
4. 网络爬虫:如何设计和实现爬虫,处理反爬策略,抓取和解析网页数据。
5. 数据同步:前端与后端的数据交互,通常通过AJAX或Fetch API实现。
6. 版本控制:Git的使用,从文件名推测项目使用了Master分支。
通过学习和理解这个项目,开发者不仅可以提升前后端开发技能,还能掌握数据库管理和数据爬取的相关技术,对于个人技能的提升和理解Web应用的全貌具有重要意义。
白话机器学习
- 粉丝: 1w+
- 资源: 7650
最新资源
- linux常用命令大全.txt
- MATLAB代码:基于粒子群算法的储能优化配置(可加入风光机组) 关键词:储能优化配置 粒子群 储能充放电优化 参考文档:无明显参考文档,仅有几篇文献可以适当参考 仿真平台:MATLAB 平台采用
- linux常用命令大全.txt
- 精品推荐-2024最新应急响应SRC实战资料合集(400份).zip
- MATLAB 实现基于金豺优化算法(GJO)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- MATLAB代码:基于NSGA-II的水电-光伏多能互补协调优化调度 关键词:NSGA-II算法 多目标优化 水电-光伏多能互补 参考文档:《店主自写文档》基本复现; 仿真平台:MATLAB
- MATLAB代码:基于分布式优化的多产消者非合作博弈能量共享 关键词:分布式优化 产消者 非合作博弈 能量共享 仿真平台: matlab 主要内容:为了使光伏用户群内各经济主体能实现有序的电能交易
- MATLAB 实现基于SMA(黏菌优化算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- MATLAB 实现基于CHOA(黑猩猩优化算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- Qt+OpenCV视觉通用框架全套源代码,包含软件和算法 完整版 包含插件式软件框架,图像采集,图像预处理,blob分析,读码,标定工具,对位工具,找直线,找圆,找椭圆,测量工具,if-else逻辑
- MATLAB 实现基于DBSCAN(基于密度的空间聚类算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- 基于麻雀算法深度优化极限学习机的故障诊断方法(SSA-DELM),分类算法,代码注释清晰,有数据例子(python代码)
- 线控转向系统 Carsim和Simulink联合仿真模型 且一个基于横摆角速度增益不变的变传动比模块 卖品包含Carsim完整数据库 【该卖品的建模方法是 动力学法】 图中分别为角阶跃工况 和
- 计算机科学中二进制操作与字符串处理:XTU-OJ系统上的101题解析及应用
- MATLAB 实现基于OOA(鱼鹰优化算法)进行时间序列预测模型的项目详细实例(含完整的程序,GUI设计和代码详解)
- 风光储交流微网(双向储能变流器) 含: 1.永磁直驱风机+mppt+整流+并网逆变 mppt采用扫描搜索法 整流采用转速外环电流内环双闭环控制 并网逆变采用电压外环电流内环控制 满功率运行 2.PV+