Django not connecting to RDS Mysql - python

I am trying to deploy my django app on EC2 and am using RDS(Mysql) as the backend.
However when I try to run gunicorn with this, the server does not respond, and the if I run python manage.py dbshell I get the error:
CommandError: You appear not to have the 'mysql' program installed or on your path.
It seems to be trying to connect to a local server of mysql when I have clearly changed the host setting the Database dict to my RDS deployment
Things I have done for solving this and trouble shooting:
1. I have changed the database settings so that they point to the RDS database.
Both the EC2 and the RDS instance are in the same zone of AWS(read this might have been the issue)
Permission could have been a problem, but I checked by trying to login from my local machine, and I was able to access the mysql commandline on my server.
Checked the database settings which django is picking up at runtime,they are correct.
Install Mysql-python, it would not install without a local installation of Mysql, so googled that , people suggested install libmysqlclient-dev first and then you should be able to install Mysql-python.
Has someone face a similar problem? What am I doing wrong here?

Related

08001] Could not create connection to database server. Index 5 out of bounds for length 5 - SQL error

I have suddenly started getting this error in my SQL client, and I really do not understand what's going on.
[08001] Could not create connection to database server. Index 5 out of
bounds for length 5
The app that I am working on is using Laravel 6, running on Homestead. I can still connect to server DBs, however I now cannot connect to any local DBs. My OS is Ubuntu 20.04 My DB client is Datagrip.
It was working fine until this started, and I haven't changed anything on my OS - I did install the mysql-connector-python package, but in a virtual env. I have uninstalled that and deactivated the venv, but still having the issue.
I am wondering if I've done my virutal env wrong, and the mysql-connector-python package has made an OS change which I'm now unable to fix.
Any help on the matter would be of great help, as I can't find much info about this specific error anywhere.
I was able to connect to the Homestead box using the box's IP Address, default MYSQL port, and the default Homestead DB username and password.
192.168.10.10:3306
username: homestead
password: secret
It should work the same with you as well. I'm also on Ubuntu and using Datagrip.

Error: 'no pg_hba.conf entry for host' using Django with PostgreSQL?

I am building a web app using Django. I am trying to connect the app to the Azure Database for PostgreSQL.
When I try to make migrations with the command, python manage.py makemigrations from PowerShell, I'm getting this error:
no pg_hba.conf entry for host
What does this error mean?
This error means you've haven't configured PostgreSQL correctly for the user you are trying to connect from Django with.
pg_hba.conf is the PostgreSQL file which contains PostgreSQL users, where from, and how they are able to connect. See here for more details:
https://www.postgresql.org/docs/12/auth-pg-hba-conf.html
You should get the same error when you try to run any Django command which needs to connect to the database, for example, python manage.py dbshell. Good luck!

Heroku download postgres DB - capture works, curl is unknown

I am doing this task the first time. I have found good documentation on how to download an existing postgres DB to local but none of the informations seem to work for me.
I need to download an existing postgres DB to local. I do this to check the entries and to have a backup because I need to work on the DB.
I have posgresql installed localy and I want to copy the heroku DB into my local DB which is named postgres. The local server has a username postgres and a password.
I have only one DB and one APP on heroku.
I tried 2 solutions.
PG:PULL
heroku pg:pull DATABASE_URL postgres
This gave me:
DL is deprecated, please use Fiddle
! The command "createdb" is written either false or
! could not be found
!
! Unable to create new local database. Ensure your local Postgres is working and try again.
So I tried with password ans username:
PGUSER=postgres PGPASSWORD=mypw heroku pg:pull DATABASE_URL postgres
This gave me:
The command "PGUSER" is written either false or could not be found
PG:BACKUPS
heroku pg:backups capture
This worked well:
Use Ctrl-C at any time to stop monitoring progress; the backup
will continue running. Use heroku pg:backups info to check progress.
Stop a running backup with heroku pg:backups cancel.
DATABASE ---backup---> b003
Backup completed
Then I used curl:
curl -o latest.dump `heroku pg:packups public-url`
Which gave me:
The command "curl" is written either false or could not be found
It seems nobody had such a problem, I dont know what I am missing. I red the whole heroku documentation and there is no such case.
EDIT
I connected to my DB via PgAdmin4 but also here I am getting the same type of error when trying to restore a DB dump file.
The PgAdmin4 log gives me:
The command "pg_restore.exe" is written either false or could not be found
I also tried to add postgresql to global path variable, but it does not seem to help:
;C:\Programme\PostgreSQL\9.6\bin\pg_restore.exe
and I tried:
;C:\Programme\PostgreSQL\9.6\bin

Postgres in Azure Flask Web App

I've got Flask up and running as per this tutorial
https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-flask-app/
I want Postgres to be my database system, but I'm in a Web App, so I can't just log into the VM and install it. What can I do here?
Thanks
It seems that we don’t have permission to install PostgreSQL database on Azure Web APP server. You need install PostgreSQL on Azure VM.
For examples:
A. If you created a Windows Server VM, refer to the link https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-tutorial/ and connect your VM.
At the link page http://www.enterprisedb.com/products-services-training/pgdownload#windows, you can download a PostgreSQL Windows Installer file and run it on your VM to install it using default configuration step by step.
The PostgreSQL default port is 2345. Make sure the Windows Server Firewall allow the port accessing and try to test the connection by using VM DNS NAME from your local host, and then you can continue to develop.
B. If you create a Linux VM such as Ubuntu,refer to the link https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-tutorial/ and connect your VM.
To install PostgreSQL, you can use Linux Package Management Tool.
Refer to the link:https://wiki.postgresql.org/wiki/Detailed_installation_guides
Ubuntu/Debian:
$ sudo apt-get update
$ sudo apt-get install postgresql
RedHat/CentOS:
Refer to the link:http://wiki.postgresql.org/wiki/YUM_Installation
You can use SQLAlchemy ORM Framework in Flask for PostgreSQL, please refer to http://flask.pocoo.org/docs/0.10/patterns/sqlalchemy/ and http://docs.sqlalchemy.org/en/rel_1_0/dialects/postgresql.html.

How to get Django to work with MySQL in XAMPP?

I installed XAMPP on my Mac (Snow Leopard) and installed Django. How do I tell Django to use this and when I fire up python manage.py runserver I get this error:
...
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)")
How do I tell Django to use this instead?
/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
Put that in the HOST entry for the database in the settings.
simple solution is that just install Django Stack for Xampp. Not need to configure any thing every thing is configured already
https://wiki.bitnami.com/Infrastructure_Stacks/BitNami_Django_Stack

Categories