Code Monkey home page Code Monkey logo

react-native-mssql's Introduction

react-native-mssql

MSSQL Native Plugin for React Native for Android

This is a basic implementation of MSSQL on Android allowing opening, closing and running sql on remote databases. This plugin does not allow an MSSQL database to be packaged locally on Android devices. The plugin only communication between remote databases.

Please let me know your projects that use these MSSQL React Native modules. I will list them in the reference section. If there are any features that you think would benefit this library please post them.

Step 1 - NPM Install

npm install --save react-native-mssql

Step 2 - Linking dependencies

react-native link react-native-mssql

Using The Plugin

import MSSQL from 'react-native-mssql';
...

Connect a Database

    const config = {
        server: '192.168.1.1', //ip address of the mssql database
        username: 'sa', //username to login to the database
        password: 'password', //password to login to the database
        database: 'admin', //the name of the database to connect to
        port: 1234, //OPTIONAL, port of the database on the server
        timeout: 5, //OPTIONAL, login timeout for the server
    }
    const connected = await MSSQL.connect(config);

Returns a promise indicating if the connection was successful.

Execute SQL

    const query = 'SELECT TOP * FROM USERS'
    const result = await MSSQL.executeQuery(query);

Returns a promise with the query results. If Getting data from a table the promise will return an array of objects for each table row.

Execute Update SQL

    const query = 'UPDATE USERS SET Active=0'
    const result = await MSSQL.executeUpdate(query);

Returns a promise with the number of rows updated. Use this method if performing INSERT, UPDATE or DELETE statements on a database.

Close a Database

    const closed = await MSSQL.close();

Closes the currently open database (if any) and returns a promise indicating if the close was successful. It is not necessary to open and close the database when required unless working with multiple databases.

react-native-mssql's People

Contributors

davidstoneham avatar soywod avatar benoitgoupilleau avatar mkahramanege 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.