OperationalError at /register/ - python-3.x

When I am trying to signup in django app on heroku, it's saying no such table: auth_user . I tried to run manage.py migrate -syncdb. It execute successfully but still the problem is same. I works perfectly in development environment.
What can be done to fix this.

I'm not sure what your auth_user model looks like, but I'm going to guess it has a Meta option of managed = False. Switching this to managed = True should resolve the issue. From the django documentation, this ensures that Django will create the necessary tables on migrate commands.
If this is not the case, please provide the code where you defined your model and I'll try an alternate route.

Related

How to Connect into a MySQL in azure server using SQLAlchemy

I need some help. I created a CRUD with Flask, and I want to conect it with my MySQL in azure. I new using Flask, so I don't know how to do it. Somebody can help me?
Now, I tried to do this:
app.config['SQLALCHEMY_DATABASE_URI']'mysql://Myuser#Myuser:MyPasswrd#MyDataBase:3306/mySchema'
My localhost works, so, I tried to change the username,passwrd and database and thought that it would work. But it didn't. I can access my Mysql-azure via workbench btw.
Thank you for reading!
I tried it here, and I got an error, I'll put a photo here. idk if this errors is because I dont have a MySQL connection, or something (I was using but I removed to see if it would work). Here a print of my instance.py and the error Instance of server
It should work after installing mysql-connector.
pip install mysql-connector
change the SQLALCHEMY_DATABASE_URI in your python script to below and create your database.
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql+mysqlconnector://{username}:{password}#{server}/testdb".format(username, password, server)
let me know if you see any specific error

How to re-run the app after crash the server in strapi?

I'm new to use strapi and I got error while add data.
Error: SQLITE_ERROR: Cannot add a NOT NULL column with default value NULL
And after that my app has gone a crash. Now I re-run the command.
strapi start
But still I got the same error. So how could I start the app again?
Two things:
1) You really shouldn't be using SQLite in production as it was never added for that purpose.
2) Based on the error it sounds like you are using develop mode in production (Content-Type builder) which also is not recommended.
You should look at using something like PM2 for autorestarts and process management
As # Lawrence Cherone suggested, I have ALTER my table to allow NULL values. And it works for me.

Implementing authentication with passport / node.js and getting error

I had already implemented authentication for the app I'm working on but am trying to refactor it based on a recent tutorial I did which I thought was very clear and also involved adding facebook / google / twitter auth which I would like to do.
So far, I've updated the user model and defined my local strategy for signup but when I go to try and run the app now, I'm getting an error. I have the app uploaded to github and wondered if somebody would be able to check it out and see where I'm going wrong. The error is pointing to a part of the index file until node_modules / express but I cannot work out what's up and I'd like to know before I proceed further.
Latest commit is under: https://github.com/DaveBage83/friendly-invention
Thanks!
A few things for you notice.
1 - Do not commit the node_modules folder. Once you have all your dependencies in the package.json file, the npm install will download all of for you again.
2 - This code is full of erros. I won't put everything here, I believe you find them by yourself. Otherwise, put the specific code here, so we can help you out.
About the question:
In you app.js file.
...
authRoutes = require('./routes/index')(app, passport)
...
If you look at the ./routes/index, you'll see that it is exporting a route object, witch does not expect the two parameters. (e.g. (app, passport)).
Hope it can still help you.

Python2 connexion framework - controller in directory structure

I am playing around with using the connexion framework to setup a REST API access for my application.
My application is is built on python2, I installed the connexion framework for python2 and played around with the yaml file via the editor (editor.swagger.io). I downloaded the Python Flask server code, converted it to be compatable with Python2 and tested for a single controller.
When the controller is placed in the same directory as the place where the server is run. Everything was fine - all routes were added and working as expected. I then proceeded to split the controller based on some business logic and wanted a tree structure for each controller.
Something like
myapp/api/magic1/magic1_controller.py
myapp/api/magic2/magic2_controller.py
and so on.
This does not work for python2. It seems to work for python3. Any ideas why?
I get the following error from logs
DEBUG:connexion.api:Security Definitions: {}
DEBUG:connexion.api:Validate Responses: False
DEBUG:connexion.api:Creating API blueprint: /api
DEBUG:connexion.api:Adding swagger.json: /api/swagger.json
DEBUG:connexion.api:Adding swagger-ui: /api/ui/
DEBUG:connexion.api:Adding /api/magic1/{name}...
ERROR:connexion.api:Failed to add operation for GET /api/magic1/{name}
In the yaml config file I add the OperationId as api.magic1.func1() and so on.
Following the information you provided here the operationId should be set to api.magic1.magic1_controller.func1 and not api.magic1.magic1.func1().
You are missing to provide more details about your problem. Code snippets would help to guide you in a more detailed solution.

What is the proper way to use the bluemix.getServiceCreds() function in node.js?

I have cloned the Concept Insights demo from Bluemix and made some minor changes to use my own corpus. It runs OK locally, but when I deploy it to Bluemix I get an authorization error when it tries to access my corpus. I'm certain that the error is a result of the early call in app.js to bluemix.getServiceCreds('concept_insights'), which apparently replaces my service credentials with some that must be stored in the environment on Bluemix.
Can someone explain the purpose of this function, and the proper approach to what I am trying to do? I could probably just delete the call to that function, but I'm afraid that I may be missing part of the larger picture if I do. Is this a way to keep my credentials out of the code base? If so, how do I make it work?
bluemix.getServiceCreds('concept_insights') gets the concept_insights service credentials from the VCAP_SERVICES variable that is created by Bluemix. (see VCAP_SERVICES)
You probably want to use the credentials from the environment instead of hardcoding them in your app.js file.
When your app runs locally you hardcode the credentials in app.js, but when it runs in Bluemix those credentials are overwritten. If you don't want this to happen remove the bluemix.getServiceCreds('concept_insights')
var credentials = {
url: 'https://gateway.watsonplatform.net/concept-insights/api',
username: '<username>',
password: '<password>',
version: 'v2'
};
When creating a service make sure you use the Standard plan.
If you use the Beta plan you will have to use https://gateway.watsonplatform.net/concept-insights/api as url.

Resources