Javascript怎么连接SQLite数据库

Javascript怎么连接SQLite数据库,第1张

js连不了, nodejs可以,用knex

npm install [email protected] --save

npm install sqlite3

var knex = require('knex')({

client: 'sqlite3',

connection: {

filename: "./mydb.sqlite"

}

})

knex.select('title', 'author', 'year').from('books').then(function(r){

console.log(r)

})

npm install [email protected] --save

npm install mysql var knex = require('knex')({

  client: 'mysql',

  connection: {

    host     : '127.0.0.1',

    user     : 'your_database_user',

    password : 'your_database_password',

    database : 'myapp_test'

  }

}) knex.select('title', 'author', 'year').from('books').then(function(data){

//取到的数据

console.log(data)

})

更多

http://knexjs.org/


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/6849724.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-29
下一篇 2023-03-29

发表评论

登录后才能评论

评论列表(0条)

保存