I'm using digitalocean managed database with django. How to create connection pool?
Related
I have a server available at AWS and the client is asking to connect to their MariaDB database remotely which is available on their server that is accessible via VPN.
So, how is it possible to connect to a remote database from the web application hosted on my AWS server?
Thanks in advance.
Context
I have a backend and API written in Python and Flask-SQLAlchemy. I use Flask-SQLAlchemy to define tables for a MySQL database, and my API routes access these tables. Previously, all my development has been on my local machine and my Flask-SQLAlchemy communicated with a local SQLite database. I currently have a Docker container with a MySQL image which contains an empty MySQL database.
What I Am Trying To Accomplish
I would like to host this API online, as well as host the Docker container (which contains a MySQL database) online. The Flask-SQLAlchemy API should communicate with the hosted MySQL database.
Options I've Considered
To my understanding, there are several options to host my API and MySQL database online.
For my API, I can either host my API onto AWS Elastic Beanstalk, or onto Docker then onto EC2.
For my MySQL database, I would like to host it onto Docker then onto EC2.
The following is how I assume I can approach this:
Problem
Should I host my Flask-SQLAlchemy API on Elastic Beanstalk, or on Docker then onto EC2? My main goal is to have my hosted API talk to a MySQL database hosted on Docker.
I have a GO server on an EC2 instance on AWS with the same VPC as my Postgres database. I'm currently able to get the server communicating with the Postgres database by reading the password from an environment variable, but I'm not sure if this is the right way to be handling this. Is there a way I can have the server communicate with the database without having the password stored in plain text?
There is no need to use your database password to connect the server with the database. Enable IAM authentication in your RDS, and attach that role with the EC2 server running the go server.
You can easily find the implementation details here.
Connecting to AWS RDS from java without exposing password
Please help me in setting up the connection between azure redis cache and aks. I am building an application where I would like to deploy it in aks and add redis as a service.
You don't connect Azure Redis to AKS, your containers running on AKS will connect to the Azure Cache for Redis instance. When connecting to an Azure Cache for Redis instance, cache clients need the host name, ports, and a key for the cache. Some clients might refer to these items by slightly different names. You can retrieve this information in the Azure portal.
https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-dotnet-how-to-use-azure-redis-cache
I have an Azure VM that runs Ubuntu and has a Django app of mine along with its postgresql database installed on it.
Moreover, I also have an Azure Web App that was created with Django, which I then connected to github, and pulled the source code for the same app I have on the aforementioned Azure VM.
I now want the settings.py in this Django Azure Web App to point to the database residing in the Azure VM.
Normally, the way to do this is to list the database url in the app's settings.py. My question is: what would be the database url for my postgresql database installed in the Azure VM, if one was to try and access it from an Azure Web App (i.e. external to the Azure VM)? Would it be: postgres://AzureVM'sFQDN:5432/nameofdatabase?
Provided you have opened port 5432 on the VM, that would be the right string to connect to your database from anywhere. Have you tried to connect your development machine to this database?
If you have created your set-up with the new resource manager deployment model of azure, you should also be able to create both the web-app and the database VM within the same virtual network. This way, you can provide access to the database only for the Web App, and not for the entire internet.