GithubHelp home page GithubHelp logo

nodedbtest's Introduction

NodeDBTest

This repository contains Node.js scripts to establish database connections for both MySQL and Microsoft SQL Server (MSSQL). These scripts can be used to verify the connectivity to the respective databases and serve as a starting point for performing various database operations.

Prerequisites:

  1. Node.js and npm should be installed on your system.
  2. Ensure you have a running and accessible MySQL server for the MySQL script.
  3. Ensure you have a running and accessible Microsoft SQL Server for the MSSQL script.

Setup:

  1. Clone the repository or download the script files (mysql_connection.js and mssql_connection.js).
  2. For each script, install the required dependencies by running the following commands in your project directory:
    # For MySQL Script
    npm install mysql2
    
    # For MSSQL Script
    npm install mssql
  3. Modify the connection_config.js file for both scripts with your respective database connection details (host, port, user, password, and database).

Connection Configuration:

  • The connection_config.js file contains the necessary configuration for connecting to the databases. Update the following details in the file:
// connection_config.js

const connection_config = {
  host: 'server-name-or-ip',
  port: 3306, // Replace this with the appropriate port for your MySQL server
  user: 'username',
  password: "password",
  database: "database-name",
};

module.exports = connection_config;

MySQL Script:

  • File: mysql_connection.js
  • Description: This script establishes a connection to a MySQL database using the mysql2 package in Node.js. It reads the connection details from the connection_config.js file and performs a basic connection test.
  • Usage:
    node mysql_connection.js
  • Outcome:
    • If the connection is successful, it will display "Connected to MySQL server!" in the console.
    • If there's an error during the connection attempt, it will display an error message indicating the issue.

MSSQL Script:

  • File: mssql_connection.js
  • Description: This script establishes a connection to a Microsoft SQL Server (MSSQL) database using the mssql package in Node.js. It reads the connection details from the connection_config.js file and performs a basic connection test.
  • Usage:
    node mssql_connection.js
  • Outcome:
    • If the connection is successful, it will display "Connected to Microsoft SQL Server!" in the console.
    • If there's an error during the connection attempt, it will display an error message indicating the issue.

Note:

  • Ensure that the respective database servers (MySQL and MSSQL) are running and accessible with the provided connection details.
  • If you encounter any issues during the connection process, double-check the configuration settings and ensure the database servers are accessible from your environment.
  • Review the options object in the mssql_connection.js script if you are connecting to a non-standard SQL Server setup, as it might need adjustments.

Feel free to extend these scripts to perform additional database operations based on your requirements. Happy coding!

nodedbtest's People

Contributors

ajalzahrani avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.