Skip to content

Example of use with SQLite #20

Closed
Closed
@ashgaliyev

Description

@ashgaliyev

When I'm trying to connect to sqlite database:

var orm = require('orm');
orm.connect('db',function (err,db) {

  if (err) {
      throw err;
  }

  res.render('index'); 
});

It gets me an error

500 TypeError: Cannot call method 'replace' of undefined
at Object.exports.connect (D:\Dropbox\sites\myblog\node_modules\orm\lib\ORM.js:49:29)

Activity

dresende

dresende commented on Jan 21, 2013

@dresende
Owner

What are you actually specifying as connection string?

orm.connect('db' // <--- what is 'db' (don't send password, send everything else)
dresende

dresende commented on Jan 21, 2013

@dresende
Owner

If you're using sqlite (there's obviously no password, duh..), you must specify as:

orm.connect('sqlite:///path/to/file', function (err, db) {
    // ...
});
ashgaliyev

ashgaliyev commented on Jan 22, 2013

@ashgaliyev
Author

Here is a full listing
var orm = require('orm');
orm.connect('sqlite://D:/Dropbox/sites/myblog/db',function (err,db) {

  if (err) {
      throw err;
  }

  var Subscriber = db.define('subscriber', {
    "id":Number
    "bill":Number,
    "fullname":String,
    "houseno":String,
    "flatno":Number
  });

  Subscriber.find(function(err,people) {
    res.render('subscribers', { activePage:'subscribers',title: 'Subscribers',subscribers:people }); 
  });

});

people is undefined

dresende

dresende commented on Jan 22, 2013

@dresende
Owner

It seems url.parse() does not handle D:/... in the URL, which is actually right. I have to update the url parser. Try this instead:

orm.connect({ pathname: "D:/Dropbox/sites/myblog/db" }, function (err, db) {
    // ...
});
dresende

dresende commented on Jan 22, 2013

@dresende
Owner

If you use this latest commit, you should be able to do:

orm.connect('sqlite://D:/path/to/file', function (err, db) {
    // ...
});
added a commit that references this issue on Sep 19, 2017

Merge pull request #20 from locomote/fix/lm-2855-fix-tests-for-all-dr…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Example of use with SQLite · Issue #20 · dresende/node-orm2