Update Query algo
This commit is contained in:
parent
6c78cae127
commit
54b7981be4
26
README.md
26
README.md
@ -116,3 +116,29 @@ const postData = await datasquirel.uploadImage({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Local Querying
|
||||||
|
|
||||||
|
You can query directly from an SQL database if you provide these environment variables in your `.env` file:
|
||||||
|
|
||||||
|
```conf
|
||||||
|
DSQL_DB_HOST=
|
||||||
|
DSQL_DB_PORT=
|
||||||
|
DSQL_DB_USERNAME=
|
||||||
|
DSQL_DB_PASSWORD=
|
||||||
|
DSQL_DB_NAME=
|
||||||
|
DSQL_SSL_DIR=
|
||||||
|
```
|
||||||
|
|
||||||
|
The ssl directory **_must_** contain a file named `ca-cert.pem`. `DSQL_DB_PORT` defaults to **3306** if not provided.
|
||||||
|
|
||||||
|
### Remote Querying
|
||||||
|
|
||||||
|
You can query from a self hosted installation of datasquirel. Just add these environment variables:
|
||||||
|
|
||||||
|
```conf
|
||||||
|
DSQL_API_REMOTE_HOST=
|
||||||
|
DSQL_API_REMOTE_HOST_PORT=
|
||||||
|
```
|
||||||
|
|
||||||
|
If these aren't provided it defaults to `datasquirel.com`.
|
||||||
|
@ -6,7 +6,8 @@ const serverError = require("./serverError");
|
|||||||
const mysql = require("serverless-mysql");
|
const mysql = require("serverless-mysql");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const SSL_DIR = "/app/ssl";
|
const SSL_DIR =
|
||||||
|
process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../ssl");
|
||||||
|
|
||||||
const connection = mysql({
|
const connection = mysql({
|
||||||
config: {
|
config: {
|
||||||
|
@ -4,7 +4,8 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const mysql = require("serverless-mysql");
|
const mysql = require("serverless-mysql");
|
||||||
const SSL_DIR = "/app/ssl";
|
const SSL_DIR =
|
||||||
|
process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
|
||||||
|
|
||||||
const MASTER = mysql({
|
const MASTER = mysql({
|
||||||
config: {
|
config: {
|
||||||
@ -12,7 +13,9 @@ const MASTER = mysql({
|
|||||||
user: process.env.DSQL_DB_USERNAME,
|
user: process.env.DSQL_DB_USERNAME,
|
||||||
password: process.env.DSQL_DB_PASSWORD,
|
password: process.env.DSQL_DB_PASSWORD,
|
||||||
database: process.env.DSQL_DB_NAME,
|
database: process.env.DSQL_DB_NAME,
|
||||||
port: process.env.DB_PORT ? Number(process.env.DB_PORT) : undefined,
|
port: process.env.DSQL_DB_PORT
|
||||||
|
? Number(process.env.DSQL_DB_PORT)
|
||||||
|
: undefined,
|
||||||
charset: "utf8mb4",
|
charset: "utf8mb4",
|
||||||
ssl: {
|
ssl: {
|
||||||
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`),
|
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`),
|
||||||
|
@ -5,7 +5,8 @@ const path = require("path");
|
|||||||
|
|
||||||
const mysql = require("serverless-mysql");
|
const mysql = require("serverless-mysql");
|
||||||
|
|
||||||
const SSL_DIR = "/app/ssl";
|
const SSL_DIR =
|
||||||
|
process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
|
||||||
|
|
||||||
let DSQL_USER = mysql({
|
let DSQL_USER = mysql({
|
||||||
config: {
|
config: {
|
||||||
|
@ -14,7 +14,8 @@ const path = require("path");
|
|||||||
|
|
||||||
const mysql = require("serverless-mysql");
|
const mysql = require("serverless-mysql");
|
||||||
|
|
||||||
const SSL_DIR = "/app/ssl";
|
const SSL_DIR =
|
||||||
|
process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
|
||||||
|
|
||||||
let NO_DB = mysql({
|
let NO_DB = mysql({
|
||||||
config: {
|
config: {
|
||||||
|
@ -5,7 +5,8 @@ const path = require("path");
|
|||||||
|
|
||||||
const mysql = require("serverless-mysql");
|
const mysql = require("serverless-mysql");
|
||||||
|
|
||||||
const SSL_DIR = "/app/ssl";
|
const SSL_DIR =
|
||||||
|
process.env.DSQL_SSL_DIR || path.resolve(__dirname, "../../../../ssl");
|
||||||
|
|
||||||
let NO_DB = mysql({
|
let NO_DB = mysql({
|
||||||
config: {
|
config: {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "datasquirel",
|
"name": "datasquirel",
|
||||||
"version": "2.3.6",
|
"version": "2.3.7",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
10
utils/get.js
10
utils/get.js
@ -49,17 +49,13 @@ async function get({ key, db, query, queryValues, tableName }) {
|
|||||||
*
|
*
|
||||||
* @description Look for local db settings in `.env` file and by pass the http request if available
|
* @description Look for local db settings in `.env` file and by pass the http request if available
|
||||||
*/
|
*/
|
||||||
const {
|
const { DSQL_DB_HOST, DSQL_DB_USERNAME, DSQL_DB_PASSWORD, DSQL_DB_NAME } =
|
||||||
DSQL_DB_HOST,
|
process.env;
|
||||||
DSQL_DB_USERNAME,
|
|
||||||
DSQL_MARIADB_ROOT_PASSWORD,
|
|
||||||
DSQL_DB_NAME,
|
|
||||||
} = process.env;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
DSQL_DB_HOST?.match(/./) &&
|
DSQL_DB_HOST?.match(/./) &&
|
||||||
DSQL_DB_USERNAME?.match(/./) &&
|
DSQL_DB_USERNAME?.match(/./) &&
|
||||||
DSQL_MARIADB_ROOT_PASSWORD?.match(/./) &&
|
DSQL_DB_PASSWORD?.match(/./) &&
|
||||||
DSQL_DB_NAME?.match(/./)
|
DSQL_DB_NAME?.match(/./)
|
||||||
) {
|
) {
|
||||||
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
/** @type {import("../package-shared/types").DSQL_DatabaseSchemaType | undefined} */
|
||||||
|
Loading…
Reference in New Issue
Block a user