parent
801507c0a1
commit
469bd3cd95
@ -1,12 +1,23 @@ |
||||
const mysql = require('mysql2/promise'); |
||||
|
||||
async function initSQL() { |
||||
const connection = await mysql.createConnection({ |
||||
const connection = await mysql.createPool({ |
||||
host: 'localhost', |
||||
user: 'root', |
||||
database: 'rgvofficial', |
||||
password: 'root' |
||||
password: 'root', |
||||
waitForConnections: true, //连接超额是否等待
|
||||
connectionLimit: 10, //一次创建的最大连接数
|
||||
queueLimit: 0, //可以等待的连接的个数
|
||||
maxIdle: 10, // max idle connections, the default value is the same as `connectionLimit`
|
||||
idleTimeout: 60000, // idle connections timeout, in milliseconds, the default value 60000
|
||||
}); |
||||
connection.getConnection(function(err, conn) { |
||||
// Do something with the connection
|
||||
conn.query(/* ... */); |
||||
// Don't forget to release the connection when finished!
|
||||
pool.releaseConnection(conn); |
||||
}) |
||||
global.SQL = connection |
||||
} |
||||
|
||||
|
After Width: | Height: | Size: 351 KiB |
After Width: | Height: | Size: 2.7 MiB |
After Width: | Height: | Size: 4.4 MiB |
Loading…
Reference in new issue