Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem while running the example js files #2

Closed
5Quintessential opened this issue Apr 11, 2016 · 14 comments
Closed

Problem while running the example js files #2

5Quintessential opened this issue Apr 11, 2016 · 14 comments

Comments

@5Quintessential
Copy link

Running the test 'database_flight_tracking.js' from the examples I am getting the following error:
"2016-04-10T17:08:18-07:00 {
"code": "ECONNREFUSED",
"errno": "ECONNREFUSED",
"syscall": "connect",
"address": "195.162.20.5",
"port": 4398,
"fatal": true
}"

After this running the 'get_cheapest_flight.js' gives the error 'Cannot find the module 'flights'
error
'

@iguanahotsauce
Copy link
Owner

That's a MySQL error, did you set up your config.js file like the example in the README.me?

@5Quintessential
Copy link
Author

I did set it up according to the readme file. But I think may be my credentials are wrong. So fixing the MySQL should fix my problem. Thank you for your quick response. I will update the issue after I successfully get past my error.

@iguanahotsauce
Copy link
Owner

Yeah that could definitely be you issue if the MySQL credentials are incorrect.

@iguanahotsauce
Copy link
Owner

Were you able to resolve this issue?

@5Quintessential
Copy link
Author

After commenting the line:

function getFlightData(data, callback) { //var request = require('request');

I was able to get the result of 'get_cheapest_flight.js'.

But I still do not have the MySQL table created. When I run the 'database_flight_tracking.js' I get the following error:

2016-04-19T19:03:59-07:00 {
"code": "ER_BAD_DB_ERROR",
"errno": 1049,
"sqlState": "42000",
"fatal": true
}

Do you know what configuration of MySQL is not set correctly? Am I supposed to create the database or will it be created programatically?

@5Quintessential
Copy link
Author

In the config file I have provided the root credentials for MySql. Is that right?

@5Quintessential
Copy link
Author

Anyway I am able to get the JSON data. That's all I wanted for the time being. Thank you so much for your response.

@iguanahotsauce
Copy link
Owner

Having to comment out the line that requires request means that you don't have it installed, which I looked in the package.json file and I realized I forgot to include that in there because I never actually used it in the code except for that line with the require. I'll update that and push the new changes back to the repo. As for the mysql database ER_BAD_DB_ERROR means that the database that it is looking for is missing. The mysql database and tables aren't created automatically, you need to run the create_tables.sql file in mysql and that will create the correct database and tables for you.

@5Quintessential
Copy link
Author

I had tried using npm install request but that too didn't help. It is only after that I resorted to comment out that line. I totally missed the SQL folder. I was able to run the script and get the tables as described. Then I executed node examples\database_flight_tracking.js and it is in a never-ending loop sort of a situation where the node command line is not getting back to prompt.

image

Neither are the database tables getting updated.

@5Quintessential 5Quintessential changed the title Cannot find module 'flights' Problem while running the example js files Apr 21, 2016
@5Quintessential
Copy link
Author

Got the following logs after sometime:

2016-04-20T17:48:22-07:00 No row in the db for the current flight, don't check price for email

2016-04-20T17:48:23-07:00 {
"code": "ER_TRUNCATED_WRONG_VALUE",
"errno": 1292,
"sqlState": "22007",
"index": 0
}

2016-04-20T17:53:22-07:00 No row in the db for the current flight, don't check price for email

2016-04-20T17:53:22-07:00 {
"code": "ER_TRUNCATED_WRONG_VALUE",
"errno": 1292,
"sqlState": "22007",
"index": 0
}

@5Quintessential
Copy link
Author

Can I delete the config.Email section? I want only in the database.

@5Quintessential
Copy link
Author

[Note: I have not used forever.js for continuous running of the Node script.]

@5Quintessential
Copy link
Author

The problem is that it is not entering anything into the database. That's why that error is returned when the query results in 0 rows.

@5Quintessential
Copy link
Author

Thank you for your support. I found that the following problems were there:

In the SQL script we must use the 'USE' statement wherever applicable and check for existence of the db before deleting and drop operations.

The date time value passed in the SQL query has a problem with the Datetime format for the departure_date column. '2016-04-21T20:05:00-04:00' is not accepted. '2016-04-21 20:05:00' is accepted. I am closing this issue as I was able to get the required data into MySql.

I will create a Pull request with the changes for SQL and index.js. You can check and merge if found to be useful.

Once again thank you for the support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants