Node.js Synchronous queries with MySQL

前端 未结 6 1995
走了就别回头了
走了就别回头了 2021-01-01 23:23

I\'m working on creating a user registration system for a website that I am working on but I am running into a few issues.

I\'m trying to stay away from having to ne

6条回答
  •  耶瑟儿~
    2021-01-01 23:37

    Symplest solution I could find is the sync-sql module. Install the required modules

    npm install sync-sql
    npm install sync-mysql 
    

    Sample index.js

    const Mysql = require('sync-mysql') 
    
    
    const connection = new Mysql({ 
        host:'localhost', 
        user:'root', 
        password:'password', 
        database:'demo'
    }) 
      
    var result = connection.query('SELECT NOW()') 
    console.log(result) 
    

    https://www.geeksforgeeks.org/how-to-run-synchronous-queries-using-sync-sql-module-in-node-js/

提交回复
热议问题