Created
September 17, 2021 17:41
-
-
Save stevesohcot/cc15b23e83542416d46fac5b0f8f641c to your computer and use it in GitHub Desktop.
Planet Scale data retrieval - Node.js on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express') | |
| const app = express() | |
| const port = 3000 | |
| const fs = require('fs'); | |
| const mysql = require('mysql'); | |
| app.get('/', (req, res) => { | |
| res.send('Hello World!') | |
| }) | |
| var sql = 'select * from users'; | |
| app.get('/users', (req, res) => { | |
| connection.query(sql, function (err, rows, fields) { | |
| if (err) throw err | |
| res.send(rows) | |
| }) | |
| }) | |
| app.listen(port, () => { | |
| console.log(`Example app listening at http://localhost:${port}`) | |
| }) | |
| const connection = mysql.createConnection({ | |
| host: 'hostNameHere', | |
| user: 'userNameHere', | |
| password: 'passwordHere', | |
| database: 'dbHere', | |
| ssl: { | |
| ca: fs.readFileSync('C:\\temp\\cacert.pem') | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment