Mssql+pyodbc connection.
Imports and db
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, Table, text, Text, Unicode, MetaData
from sqlalchemy.orm import relationship
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
I have generated table models using flask-sqlacodegen which look like this
class BlaBla(db.Model):
__tablename__ = 'bla_bla'
blabla= db.Column(db.Integer, primary_key=True)
bla2= db.Column(db.Integer, nullable=False)
The view that I have in the db was generated like this
t_bla_bla_bla_view = Table(
'View_bla_bla_bla',
Column('irrelevant', db.Unicode(50), nullable=False),
Column('etc', db.Unicode(50), nullable=False),
Column('etc2', db.Unicode(50), nullable=False)
)
When I run flask db migrate, the tables are properly created, while the View is also created as a table. What is the actual syntax on creating a view? Maybe there is a raw query migrate workaround?