I am creating a node-red API service that access SQLite database using SQLite node.
How to configure the database with SQLite node?
I have hard-coded db file in SQLite node.
What is the right way to develop a node-red API that access the SQLite database ?
I think I want to make the database filename configurable, so that it is fetched dynamically.
I am new to node-red programming.
If the changes are only at deploy time not runtime then you can use Environment variables as described in the doc here
If you replace the path to the DB in the config node with ${DB_PATH} then Node-RED will replace this with the value of the DB_PATH environment variable at deploy time.
Have you looked at the documentation for creation configuration nodes?
https://nodered.org/docs/creating-nodes/config-nodes
Related
I have a server implemented on Adonis.js with tests that perform operations against the main database. I want to use #Adonis.js/Vow and create a sqlite database dedicated only to use on the tests. The server is running on docker, and i use a docker-compose file to build the complete solution (3 servers and 2 other databases on postgreSQL). How can i create a sqlite database on docker to run it and connect to it on my tests?
Like always, the first step is to install the package from npm by running the following command.
npm i #adonisjs/lucid#alpha
Once done, run the following command to set up the package.
node ace invoke #adonisjs/lucid
1.You can choose sqlite of the available databases.
Right after the setup command is completed, we need to copy the code for validating the environment variables to the env.ts file. Since environment variables are injected from the outside, AdonisJS recommends you validate them and ensure that your app is always running with the correct set of configuration values.
The config/database.ts file holds all the configuration related to the database.
Finally, the config file relies on the environment variables and you can update them inside the .env file.
PG_HOST=localhost
PG_PORT=5432
PG_USER=root
PG_PASSWORD=
PG_DB_NAME=tests
learn more
database introduction
I'm already using db-migrate package to migrate MySQL database script and it works well, I've even setup the DATABASE_URL variable in the server environment.
Now I've a requirement to store few details in the sqlite in the same service, I checked db-migrate package for this feature apparently nothing mentioned regard to the executing sql scripts in multiple different databases at one go. Is it possible to do in db-migrate? or do I've to write my own service for this?
I have installed thingsboard on Linux. initially it was using Cassandra database, but now i have changed it to postgresql. But the issue is that both the thingsboard and postgresql are not running. The only error in postgresql log file is "Incomplete startup Packet" and thingsboard log file has "all hosts tried query failed(tried: /127.0.0.1:9042)" error.
I have stopped the Cassandra service and also configured the thingsboard.yml file to use postgresql database.
How to fix this issue.
Without knowing more log details, I suggest to fresh install a new ThingsBoard+PostgreSQL instance and migrate the Cassandra db to the new instance using the REST API feature of ThingsBoard, this way you avoid the corruption of PostgreSQL.
The steps are:
Install a new instance of ThingsBoard and PostgresSQL
Retrieve data via REST API from old instance
Send data via MQTT or other supported protocols to new instance
You can find a script which does this automatically in this repo.
I am not sure but In my experience that you should check up as below.
install PostgreSQL on your server.
create database like thingsboard inside postgreSQL.
configure for using PostgreSQL in thingsboard.yml
Run installation script again
https://thingsboard.io/docs/user-guide/install/linux/#memory-update-for-slow-machines-1gb-of-ram
I am creating a NodeJs Desktop application using node-webkit and right now using MongoDB as a database.
I want to distribute it as an executable where users will be able to use the application without installing the database by utilizing their own copy of local DB.
Is there a way i can make a local copy for their DB during the installation.
If it is not possible in MongoDB, what other DB should i use?
well its based on your data needs, if you have large set of data you should use mongoDB otherwise there are lots of databases for your NWJS app. check this link https://github.com/nwjs/nw.js/wiki/Save-persistent-data-in-app some of them are good enough to hold big data. but personally i prefer sqlite3 with NWJS(there is a lot of hustle to install it for NWJS) sqlite can work with large data check this page for more info.
if you are going with mongoDB then you should download the the zip not the installer and pack it with your installer the you should be good to go.
by default mongoDB stores its data in /data/db but you can change it to your preferred location
I am running Etherpad Lite on windows, and apparently it is persisting pads across shutdowns. But where? Does it run sqlite inside the node.exe process? What files does it use to store whichever database it might be using?
They use dirtyDB as its datastore if you dont specify a postgres, sqlite or mysql configuration in $APPDIR$/settings.json
The dirtyDB file path is also set in the settings.json file. -- They recommend using dirtyDB only for testing.