Browse Source

上传文件至 '前端/cloudfunctions/mysql'

master
李思涵 3 years ago
parent
commit
0bbf0895d4
4 changed files with 2301 additions and 0 deletions
  1. +4
    -0
      前端/cloudfunctions/mysql/config.json
  2. +27
    -0
      前端/cloudfunctions/mysql/index.js
  3. +2255
    -0
      前端/cloudfunctions/mysql/package-lock.json
  4. +15
    -0
      前端/cloudfunctions/mysql/package.json

+ 4
- 0
前端/cloudfunctions/mysql/config.json View File

@ -0,0 +1,4 @@
{
"permissions": {
}
}

+ 27
- 0
前端/cloudfunctions/mysql/index.js View File

@ -0,0 +1,27 @@
// 云函数入口文件
const cloud = require('wx-server-sdk')
//引入mysql操作模块
const mysql = require('mysql2/promise')
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
try {
const connection = await mysql.createConnection({
host: "sh-cynosdbmysql-grp-102eitfe.sql.tencentcdb.com",
port:23345,
database: "yicanyishi",
user: "Test",
password: "1Canyishi"
})
const [rows, fields] = await connection.execute('SELECT version();')
connection.end()
return rows;
} catch (err) {
console.log("链接错误", err)
return err
}
}

+ 2255
- 0
前端/cloudfunctions/mysql/package-lock.json
File diff suppressed because it is too large
View File


+ 15
- 0
前端/cloudfunctions/mysql/package.json View File

@ -0,0 +1,15 @@
{
"name": "mysql",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"mysql2": "^2.3.3",
"wx-server-sdk": "~2.5.3"
}
}

Loading…
Cancel
Save