Giter Site home page Giter Site logo

database_examples's Introduction

Database examples using Node and MySQL

These examples illustrate the handling of asynchronous database queries using the npm mysql package. In the examples, database tables are created and data is inserted into one of the tables. The data to be inserted is obtained by reading it from an external JSON file.

1-db-naive.js

This example shows how failing to recognize the asynchronous nature of the database queries leads to an error caused by prematurely closing the database connection.

2-db-callback.js

This example correctly closes the connection when all queries have finished. It uses traditional callbacks.

3-db-promise.js

Here, the callbacks are replaced by promises. The functions returning promises are hand-coded.

4-db-async.js

This final version uses async/await and util.promisify().

database_examples's People

Contributors

remarcmij 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.