Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
This is a library to execute MySQL SQL files in directories.
It is not meant to be executed directly on the command line, although it can be used as the basis to create command line utilities to deploy SQL.
npm install exec-sql
Connects to a given database. Currently always use 'localhost' as it was enough for our internal needs so far, but it will be specifiable as an argument in a future version.
connect(connectionObj)
mysql.createConnection
. At the very least, the properties 'database', 'user' and 'password' should be set. The 'host' property will be set to 'localhost' if absent and the 'multipleStatements' will always be set true.Returns the database connection.
Disconnects from the database
disconnect()
None.
Execute a given SQL file.
executeFile(file, callback)
A promise will be returned if a callback is not passed as the second argument, else nothing will be returned.
Execute all SQL files in a given directory. SQL files are identified by their '.sql' ending in the file name. Currently, sub-directories are ignored.
In future versions, sub-directories will be traversed recursively.
executeDirectory(directory, callback)
A promise will be returned if a callback is not passed as the second argument, else nothing will be returned.
//Let's say that we want to execute all SQL files in the relative 'views' directory in database 'mysql' with user 'root' that has the equivalent password.
var execSQL = require('exec-sql');
var path = require('path');
execSQL.connect({
'database': 'mysql',
'user': 'root',
'password': 'root'
});
execSQL.executeDirectory(path.join(__dirname,'views'), function(err) {
execSQL.disconnect();
console.log('Done!');
});
You can run the tests either directly on your host or in a dockerized work environment (I personally recommend the later).
Run the following:
yarn install
yarn run test
Note that you'll need to have docker and docker-composed installed.
Run the following:
docker-compose up -d database
Note that you might have to wait a bit for the database server to properly start. You can look at the mysql server logs to infer status by typing:
docker-compose logs database
Then, run any of the 3 commands below (by default, the workspace is boron aka node 6):
docker-compose run workspace
docker-compose run workspace-argon
docker-compose run workspace-carbon
Then, from inside the workspace, type:
yarn install
yarn run test
To exit the worspace (when inside), type:
exit
To cleanup, from outside the worspace, type:
docker-compose down --volumes
The tests will output some error logs on the screen. That is normal (as long as you get an indication at the end that all the tests passed) as error paths in the code are tested as well.
locahost -> localhost
Added 'file' as a propertie to logged errors when calling executeDirectory.
Added installation instruction and corrected error in example.
Original Release
FAQs
Library to execute SQL files in a directory
We found that exec-sql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.