Vietnam

    Nodejs.vn

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Groups
    • Search

    npm sqlite-json dường như không hoạt động???

    Node.JS
    0
    4
    643
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Thuc Nguyen tan
      Thuc Nguyen tan last edited by Thuc Nguyen tan

      
      
          /*
          const SqliteToJson = require('sqlite-to-json');
          const sqlite3 = require('sqlite3');
          const exporter = new SqliteToJson({
            client: new sqlite3.Database('../tin_tuc.sqlite3')
          });
          exporter.tables(function (err, tables) {
              // all your table names here
              console.log(tables);
              var data= {kq:tables}
              res.render('sqlite_to_json/index', data );
          });
      */
      
      
          const sqliteJSON = require('sqlite-json');
          //const exporter = sqliteJson('example.db');    
          const sqlite3 = require('sqlite3');
          var db = new sqlite3.Database('../tin_tuc.sqlite3');
          const exporter = sqliteJSON(db);
      
          // exporter.tables(function (err, tables) {
          //     // tables === ['foo', 'bar', 'baz'] 
          //     console.log(tables);
          //     var data= {kq:tables}
          //     res.render('sqlite_to_json/index', data );
          // });    
      
      
          exporter.json('select * FROM TinTuc', function (err, json) {
              // handle error or do something with the JSON 
              // "[{"foo": 1}, {"foo": 2}, {"foo": 3}]" 
              console.log(json)
              var data= {kq:json}
              res.render('sqlite_to_json/index', data );
          });
      
      
      
      
      
      
      
      

      Một đống code này đều không chạy ???

      tất cả đều trả về array rỗng []...

      cả 2 npm luôn : sqlite-to-json và sqlite-json

      ace có ai thử chưa ?

      Vũ 1 Reply Last reply Reply Quote 0
      • Vũ
        Vũ Global Moderator @Thuc Nguyen tan last edited by

        @Thuc-Nguyen-tan Mình chưa thử nhưng bạn có chắc chắn file tin_tuc.sqlite3 có dữ liệu ko? 😃

        Tech-nông
        Email: [email protected]
        Profile: about.me/vunb
        Github: github.com/vunb
        Twitter: twitter.com/nhubaovu

        1 Reply Last reply Reply Quote 1
        • Thuc Nguyen tan
          Thuc Nguyen tan last edited by Thuc Nguyen tan

          absolutely sure, file mình tạo và đang chạy mà...

          gửi luôn :

          link text

          1 Reply Last reply Reply Quote 0
          • Thuc Nguyen tan
            Thuc Nguyen tan last edited by

            ok mình làm được rồi nhé, đặt đường dẫn sai.....cám ơn

            1 Reply Last reply Reply Quote 0
            • First post
              Last post