CJ F
CJ F

Reputation: 835

meteor-mysql package not working

I'm trying to access a MySQL database with Meteor using the meteor-mysql package here...

meteor-mysql package

It is supposedly a wrapper around the node mysql river, but I cant get it to work.

When I do this....

           console.log("connecting to MySQL")
            var connection = Mysql.createConnection({
                host: '111.111.111.111',
                user: 'username',
                password: 'password'
            });

            connection.connect(function (err) {
                if (err) {
                    console.log('error connecting: ' + err.stack);
                    return;
                }
                console.log('connected as id ' + connection.threadId);
            });

            connection.destroy();
            console.log('connection destroyed');

I get two messages on the console. "connecting to MySQL" and "connection destroyed".

Needless to say, I can't get queries working either, but even more frustrating is that I can't get any indication of error other than silence. What is going on here?

Upvotes: 0

Views: 136

Answers (1)

Tarang
Tarang

Reputation: 75945

You're destroying the connection as soon as you try to connect:

Remove these lines:

connection.destroy();
console.log('connection destroyed');

Running connection.destroy() tells the module to disconnect. If you copy pasted it from somewhere the intention was to place the whole block of code into a single piece to understand it easily, but its only meant to be run when you want the connection to stop.

Upvotes: 2

Related Questions