title: Transform flask with sqlite to Flask with postgres
body: <p>I have developed a simple flask app locally where I was using SQLite database to perform the login. Now I have deployed it to Heroku and realized that Heroku doesn't support SQLite, that's why now I need to change it to another database.</p>
  
  <p>Here's what I have done with SQLite:</p>
  
  <p>Here's how i have created table:</p>
  
  <pre><code>from sqlalchemy import create_engine
  from sqlalchemy import Column, Date, Integer, String
  from sqlalchemy.ext.declarative import declarative_base
  
  engine = create_engine('sqlite:///tutorial.db', echo=True)
  Base = declarative_base()
  
  # Create USER model
  
  class User(Base):
      __tablename__ = "users"
      id = Column(Integer, primary_key=True)
      username = Column(String)
      password = Column(String)
  
      def __init__(self, username, password):
          self.username = username
          self.password = password
  
  Base.metadata.create_all(engine)
  </code></pre>
  
  <p>Here's how i'm using SQlite for login:</p>
  
  <pre><code>from sqlalchemy.orm import sessionmaker
  engine = create_engine('sqlite:///tutorial.db', echo=True)
  
  @app.route('/login', methods=['GET', 'POST'])
  def lodadata():
      POST_USERNAME = str(request.form['uid'])
      POST_PASSWORD = str(request.form['upass'])
  
      session = sessionmaker(bind=engine)
      s = session()
      query = s.query(User).filter(User.username.in_([POST_USERNAME]),
                               User.password.in_([POST_PASSWORD]))
      result = query.first()
      if result:
          session['logged_in'] = True
      else:
          flash('Something wrong about Login Detail')
  </code></pre>
  
  <p>How can I change my database to another DB which supported by Heroku?</p>
  
  <p>Help me, please!</p>
  
  <p>Thanks in advance!</p>