I am trying to use PostgreSQL with Flask-SQLAlchemy. I made a database named data_collector
using pgAdmin4. When I try to create a table it's not getting created. I think the connection to the database is not getting established.
I am trying to run it from cmd as:
from app import db
db.create_all()
from flask import Flask, render_template,request
from flask_sqlalchemy import SQLAlchemy
app=Flask(__name__)
app.config['SQLALCHEMY DATABASE_URI'] = 'postgresql://postgres:postgresql@localhost/data_collector'
db=SQLAlchemy(app)
class Data(db.Model):
__tablename__="data"
id=db.Column(db.Integer,primary_key=True)
email_=db.Column(db.String(120),unique=True)
height_=db.Column(db.Integer)
def __init__(self,email_,height_):
self.email_=email_
self.height_=height_
db.create_all()