npm oracledb logging and tracing - node.js

My goal is to enable logging and tracing for the oracle database using the oracle client and npm package oracledb so that I can check when the query was started and when results were returned or if the query was timed out.
More precisely I want to check if it's the oracle client which is taking the time or if there is something wrong with the oracledb package.
I want to check logs for any errors and want to trace slow queries or queries for which a timeout error has occurred or any deadlock that occurs.
So far I'm successfully able to enable logging and tracing for the oracle database client and it's working only when I use sqlplus CLI but when it comes to the oracledb npm package it's not working.
I have created sqlnet.ora in $ORACLE_HOME/network/admin directory, and then pasted this content to enable logging and tracing for oracle-client.
LOG_DIRECTORY_CLIENT=C:\Oracle\instantclient_21_3\network\admin\cl-log
LOG_DIRECTORY_SERVER=C:\Oracle\instantclient_21_3\network\admin\srv-log
LOG_FILE_CLIENT=client
LOG_FILE_SERVER=svr.log
TRACE_LEVEL_CLIENT=ADMIN
DIAG_ADR_ENABLED=ON
ADR_BASE=C:\Oracle\instantclient_21_3\network\admin\log-adr
And as far as the implementation of oracledb with NodeJs is concerned I create connection pools using oracledb.createPool({...config}) and then when I need to query into DB I use oracledb.getPool('poolName').execute(query).
To me, the error is that it creates random .trc files and does not put logs to the sqlnet.log file only when using the oraceldb npm package.

Related

Python: Error while connecting to SQL Server (ODBC 17)

Getting below error while executing SQL statement using pd.read_sql()
sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('08001',
'[08001] [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL
Provider: [error:0A0C0103:SSL routines::internal error] (-1)
(SQLDriverConnect)')
Python version 3.10.8. Other packages:
pyodbc==4.0.35
pandas==1.5.2
pymysql==1.0.2
sqlalchemy==1.4.46
I want to execute the above command successfully.
The error message 'ODBC 17' distinctively specifies a failure in establishing a connection to a SQL Server database through ODBC driver. This can be caused by;
Incorrect connection details such as server name, database name, username, and password.
ODBC driver not installed or not properly configured on the machine.
In order to solve this, try and verify the connection details and ensure they are correct or Install or reinstall the ODBC driver and make sure it's properly configured.
If the above doesn't work, kindly check the firewall settings and ensure that the connection is not being blocked.
Hope this helps.

Execute SQL file which contains multiple stored procedures in Node.js?

How can I execute a SQL file which contains multiple stored procedures and a lot of SQL script in Node.js?
I have tried to execute the sql file using npm package execsql but it doesn't work. Here is the link which I have tried.
Able to install
Did DB configuration
Getting this error while executing sql statement or sql file:
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'usernane'#'myipaddress' (using password: YES) –
Yet I am able to execute sql statements using npm package mysql with the same db configuration.

Issue with sequelize migrations to heroku

I have been sitting at this computer for 7 hours straight trying to deploy my app. There is a node/express backend serving up restricted API json data at different endpoints. In order to get access to this json data you have to have a token.
It all works fine and dandy on my local server during development. However, when I go to send the migrations to heroku (using 'heroku run bash', then 'sequelize db:migrate), I get some random error saying "SyntaxError: Unexpected String"..as shown below.
As you can see, when I run sequelize:db:migrate:undo, it says that no executed migrations found.
```
Sequelize [Node: 5.11.1, CLI: 2.4.0, ORM: 3.24.3, pg: ^6.1.0]
Loaded configuration file "config/config.json".
Using environment "production".
== 20160917224717-create-user: migrating =======
[SyntaxError: Unexpected string]
~ $ sequelize db:migrate:undo
Sequelize [Node: 5.11.1, CLI: 2.4.0, ORM: 3.24.3, pg: ^6.1.0]
Loaded configuration file "config/config.json".
Using environment "production".
No executed migrations found.
~ $
```
However, when I look in my heroku database, I DO see that there is now 1 table. However, that table does not work, and I am still getting an error on form submit to create a user. The error I get on form submit is:
message: "relation "users" does not exist"
name: "SequelizeDatabaseError"
What gives? This alleged syntax unexpected string error does not throw when I am running locally. It runs smooth as butter with the migrations. What could this be?
Thanks.
Either you have not updated your code on the server to match your local environment or your database does not match. "Users relation" implies the users table is related to another table. Make sure the code is really updated (if sequelize code mentions this relation) AND all other tables are reproduced on the server.
Once I got a problem with accessing postgres db on Heroku (provided as an add-on):
I installed SQL Shell (psql) on my laptop
I logged-in to the db (used all necessary credentials)
run: \dt to check db schema => result: 'no relations', so the migration wasn't done yet
run migrate:db
run: \dt => schema is here - OK!
now: run heroku console
login to your account
run: heroku restart -a=<my_app>
If the lack of db:migration was a problem only, it should be fine now.
You can also try to reset your db first (if your data isn't precious!) running: heroku pg:reset -a=<my_app>

NodeJS/Express: ECONNRESET when doing multiples requests using Sequelize/Epilogue

I'm building a webapp using the following the architecture:
a postgresql database (called DB),
a NodeJS service (called DBService) using Sequelize to manipulate the DB and Epilogue to expose a REST interface via Express,
a NodeJS service called Backend serving as a backend and using DBService threw REST calls
an AngularJS website called Frontend using Backend
Here are the version I'm using:
PostgreSQL 9.3
Sequelize 2.0.4
Epilogue 0.5.2
Express 4.13.3
My DB schema is quite complex containing 36 tables and some of them contains few hundreds of records. The DB is not meant to write data very often, but mostly to read them.
But recently I created a script in Backend to make a complete check up of datas contained inside the DB: basically this script retrieve all datas of all tables and do some basic checks on datas. Currently the script only does reading on database.
In order to achieve my script I had to remove the pagination limit of Epilogue by using the option pagination: false (see https://github.com/dchester/epilogue#pagination).
But now when I launch my script I randomly obtained that kind of error:
The request failed when trying to retrieve a uniquely associated objects with URL:http://localhost:3000/CallTypes/178/RendererThemes.
Code : -1
Message : Error: connect ECONNRESET 127.0.0.1:3000
The error randomly appears during the script execution: then it's not always this URL which is returned, and even not always the same tables or relations. The error message before code is a custom message returned by Backend.
The URL is a reference to the DBService but I don't see any error in it, even using logging: console.log in Sequelize and DEBUG=express:* to see what happens in Express.
I tried to put some setTimeout in my Backend script to slow it, without real change. I also tried to manipulate different values like PostgreSQL max_connections limit (I set the limit to 1000 connections), or Sequelize maxConcurrentQueries and pool values, but without success yet.
I did not find where I can customize the pool connection of Express, maybe it should do the trick.
I assume that the error comes from DBService, from the Express configuration or somewhere in the configuration of the DB (either in Sequelize/Epilogue or even in the postgreSQL server itself), but as I did not see any error in any log I'm not sure.
Any idea to help me solve it?
EDIT
After further investigation I may have found the answer which is very similar to How to avoid a NodeJS ECONNRESET error?
: I'm using my own object RestClient to do my http request and this object was built as a singleton with this method:
var NodeRestClient : any = require('node-rest-client').Client;
...
static getClient() {
if(RestClient.client == null) {
RestClient.client = new NodeRestClient();
}
return RestClient.client;
}
Then I was always using the same object to do all my requests and when the process was too fast, it created collisions... So I just removed the test if(RestClient.client == null) and for now it seems to work.
If there is a better way to manage that, by closing request or managing a pool feel free to contribute :)

MemSQL select query 1705 error

I am using memsql community version and I am able to execute some queries but getting error for few queries like
select * from policy;
Error code:
ERROR 1705 (HY000): The query cannot be executed.
MemSQL code generation has failed: Failed to delete .fin file.
This likely indicates a permissions problem or some other issue with your installation ([install dir]/plancache may not be writable by memsqld for example). Did you install and start MemSQL via Ops?
There will probably be a more detailed error message inside of
[install dir]/tracelogs/memsql.log

Resources