Cassandra Connection Problem in Heroku deployment - python

Hi I have deployed a Flask (ML Project) in Heroku cloud and the app is published. But when I try to predict the model, it gave an error of database connection. When I debug I found out that the connection to the cassandra db is not working. Here was my code
self.cloud_config = {'secure_connect_bundle': "cassandraconnection\\secure-connect-test.zip"}
self.auth_provider = PlainTextAuthProvider('XXX','XXX')
self.cluster = Cluster(cloud=self.cloud_config, auth_provider=self.auth_provider)
The secure-connect-test.zip file is located in the project directory itself. But still i am getting the error
No such file or directory: 'cassandraconnection\\secure-connect-test.zip'
Can anyone suggest where I am making the mistake. Or how to solve this issue

It's very likely that where you think the secure bundle should be and where Heroku is looking for it don't match.
We recommend that you always specify the full path to your Astra DB secure connect bundle to avoid confusion. Cheers!

Related

Flask not opening SQLite Database on apache2

I have been moving my flask apps from replit to my server, and things have been going smoothly, but I am moving my first app with SQL in it over to the server, and there keeps being errors when I open the database in the code. In the Apache error log, it says:
sqlite3.OperationalError: unable to open database file
The app works well on replit, the database is in the same folder, but it doesn't work. Does anybody know why? I am using Ubuntu Server 20.04
I have figured out why it's not working! The database was in the same dir as init.py, but wsgi calls it as a module in a different dir, so it wasn't calling the db. Adding an absolute path eg. /var/www/theapp/theapp/database.db works.

Getting internal server error after deploying the project on Heroku

I have deployed NLP project on Heroku server. If I am going to test the webapp by entering the fields, then I get INTERNAL SERVER ERROR:
The server encountered an internal error and was unable to complete your request.
Either the server is overloaded or there is an error in the application.
This app is successfully running on localhost. I don't know what happens after deployment.
Can anyone help?
Here is the screen shot of build
[
Here is the code of app.py file
This is the code of spam_classifier.py
These are requirements which I put on requirements.txt
It seems like your build got successfully deployed but you are getting the internal server error while you are consuming the API.So you will have to check the application log instead of the build log. To see that, in the heroku dashboard go to more>>logs. For every request that you make, you will be able to see the logs and hence the runtime errors if there are any.
Few other suggestions
You don't need spam_classifier.py in your file system on the deployed environment as you are loading the trained model from the pickle file.
Make sure that you have pushed the pickle files along with the code. I suggest that you use amazon s3 to store and load those kind of files
If you check the Application Logs in heroku you will find this error "Error R14 (Memory quota exceeded)" due to which you are getting the Internal Server Error after deploying the project on Heroku.

Why can my flask app no longer access my SQLite3 dabatase after being moved to a Ubuntu virtual machine?

I've made a flask project that worked without errors. Once I moved it to a ubuntu virtual machine for deployment, trying to deploy it using gunicorn/ nginx or apache2/ mod_wsgi raises the same error:
conn = sqlite3.connect('../db/bandwidthburst.db', check_same_thread=False)
sqlite3.OperationalError: unable to open database file
On similar questions the advice was to make sure the user has write permissions, so I've done 'chmod ugo+rwx' for my database, its parent folder and the parent folder to that aswell, which did not change the results.
Any help in fixing this would be much appreciated, thank you.
Now connects after changing the url to '/var/www/.../bandwidthburst.db'!
Going through fixing other errors now

database configuration in pyramid

I tried to create a sqlalchemy project in pyramid and when I run the server, I get this error,
Pyramid is having a problem using your SQL database. The problem
might be caused by one of the following things:
1. You may need to run the "initialize_MyProject_db" script
to initialize your database tables. Check your virtual
environment's "bin" directory for this script and try to run it.
2. Your database server may not be running. Check that the
database server referred to by the "sqlalchemy.url" setting in
your "development.ini" file is running.
After you fix the problem, please restart the Pyramid application to
try it again.
when I check my development.ini file the sqlite database is configured as this,
sqlalchemy.url = sqlite:///%(here)s/MyProject.sqlite
What needs to changed in here to configure it correctly?
I run on linux box.
You need to create a database in either sqlite,postgres,or any other,Thereafter go to development.ini file edit sqlalchemy.url = sqlite:///%(here)s/MyProject.sqlite and specify the name of your database,then run the initialize_myproject_db development.ini command.if you are using mysql, that line should be
sqlachemy.uri = mysql://username:password#host/dbname
Just trying Pyramid for the first time, I just faced the same problem, after many command combinations, I just got the solution.
Run from the project root, the command:
initialize_tutorial_db development.ini
Info taken from Wiki2 SQLAlchemy tutorial
It says right there in the first point - you need to run initialize_MyProject_db development.ini to create database.
If that's not the case please post the log from running the server.

How do I use web2py on Heroku?

I'm having a lot of trouble with getting web2py to work on Heroku. I can't even get a basic app to work. Whenever I go to my herokuapp page, it says
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details."
It may be a problem with the DB setup. By default web2py only supports sqlite or Google App Engine (GAE). It's probably trying to initialize sqlite databases on Heroku's read-only filesystem.
Either disable the DB code temporarily to see if this is indeed the case, or configure a connection to a supported database (MySQL, S3, etc).
Take a look at the "official" Heroku script in scripts/setup-web2py-heroku.sh
Try with a simple wsgi application first. Here is some tutorial: http://webpython.codepoint.net/wsgi_tutorial
Web2py will work without any problems if you can run simple wsgi apps.

Categories

Resources