---
# System prepended metadata

title: Cloud Native Database

---

# Cloud Native Database
## Install Database Server
Install PostgreSQL from official website:
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads

then open pgAdmin4 and create a database.

## Install Flask
```
conda create -n cloud python=3.9 -y
conda activate cloud
conda install -c anaconda flask
conda install -c conda-forge flask-sqlalchemy
conda install -c conda-forge psycopg2-binary
```

## Run Test
```
from flask_sqlalchemy import SQLAlchemy
from flask import Flask
 
db = SQLAlchemy()
 
app = Flask(__name__)
 
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://postgres:vincent@127.0.0.1:5432/test"
# "postgresql://user_name:password@IP:5432/db_name"
 
db.init_app(app)
 
@app.route('/')
def index():
    sql_cmd = """
        select *
        from account
        """
 
    query_data = db.engine.execute(sql_cmd)

    result = ""
    for row in query_data:
        print(row)
        result += str(row[1]) + ' '
    
    return '<html><body><h1>{}</h1></body></html>'.format(result)
 
 
if __name__ == "__main__":
    app.run()
```