How to use django with sql server database from other server? - python

I'm planing to built an app using Django with SQL Server. But I'm going to develop the app in my computer but the database is already exist in other computer/server.
How can I connect to that database in the other server and connect the Django which is in my computer? They are separate computers.

Related

Why does my Django login work on development server but not production server?

I have an issue where I can login to Django via my development server but it will not work on the production server. I am using Heroku to deploy. All the pages work correctly but I can't login to my Django database.
Your user credentials are stored in your database.
If you have a different database Server in Production which is hosted online it won’t have the credentials stored that you have in your local development database.
So you basically have to get into your deployed Django app using ssh or so and run „createsuperuser“ there again.
Alternatively you could copy the user credentials from you local database and push them to your production database; but just creating new ones will probably be easier if you don’t have to deal with a lot of users.
If you were using Django with „default settings“ it is using an SQLite file (= database).
In Production for a Webapp hosted online it will be most likely a „real database server” (DBMS) like PostgreSQL or MySQL or so as SQLite is fine for development and testing, but struggles with concurrent user access to data.
If you are configured different database in your production server you have to execute migrations and createsuperuser. Then you'll able to login.
Your current user credentials are saved in your database which is configured in local server.

An app deployed to Heroku can't access to MySQL database in cPanel remotely

i am deploying a python app to Heroku, an there is an error when accessing the app after deployment,
(pymysql.err.OperationalError) (2003, "Can't connect to MySQL server
obviously it is about my login system which is using MySQL to store the usernames and passwords.
Now this database sits in my cPanel, and i have already set the Remote MySQL Access hosts to a wild card "%" (trying to allow all incoming request from all ips to this database).
But now it seems this app on Heroku can't access to this database. Any solution for that?
Any help is appreciated.
if it helps create a php database query api script on your server that hosts the database and access it from your python code on heroku with requests package.

How to use Django with PGBouncer?

I have an application launched in Django, which has a very high traffic of requests and queries to the databases. I am having problems and I have read that with PGBouncer and some settings in Django I can solve the problem.
The question is how to integrate PGBouncer with Django.
I have the Django application in Docker.
The database is Postgres and it is in the RDS service of Amazon web services.
Would PGBouncer be installed on the instance where the Django application runs?

How to upload local mysql database to heroku app?

I have a web application written in Python-Flask with database created using MySQL. I have deployed my app using Heroku but it's only the frontend and backend part. I also need to upload database so that the app can interact with the database. I have searched many videos on YouTube but nothing came as useful. Most of them are using Postgre SQL both in local and heroku app but I've an MySQL database with me. I need help how can I connect my app to my database.
Heroku has native support for postgessql not mysql, so you might want to change to that or use the Clear DB addon as explained in the docs.
From heroku
"Heroku provides three managed data services to all customers:
Heroku Postgres, Heroku Redis, Apache Kafka on Heroku"
Also have a look at this previous answer that targets the same issue.

Postgresql: migrating local database to the PythonAnywhere database

I've followed the Djangogirls tutorial and usually the tutorial calls for you to create a database on pythonanywhere. This usually works without a hitch when using sqlite3 however this time I'm using postgresql and I got the below error when I ran the migrate command in the console:
conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql
What does this mean exactly?
using python 3.5.1
django 1.9.8
postgresql 9.4
Thanks
Ok after reading around some more, this is my problem in a nutshell.
I have postgresql running locally. I then deployed the wbapp onto pythonanywhere. Whilst there I tried to create the database by running migrate which resulted in the above error.
Since then i realised that I had to setup postgresql to run on pythonanywhere. I followed the instructions and did that, but what I don't understand is do I now have to create the database from scratch? And if that is the case what happens to all my tables etc. from my local database?
To clarify, you should not be trying to connect to your local postgres. Instead, you should setup postgres on pythonanywhere, and make sure that your django settings.py is pointing the database address and port to the pythonanywhere database. Which is not local to the console/webapp server that you are running your code on. Instead, go to the pythonanywhere database tab and look at the address/port that is given to you.
According to their help page you need to upgrade to a paid account to be able to use postgres.

Categories