Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask sqlAlchemy: Creating models for the existing database structure

I am new to sqlAlchemy and I wonder if there is a way create a class that would be mapped to the existing table in DB without specifying any columns of the table (but all columns could be accessed as attributes of the object)?

like image 326
Slavskii Sergei Avatar asked Aug 03 '26 04:08

Slavskii Sergei


1 Answers

This is how I generated models for flask-sqlalchemy which use MS SQL.

flask-sqlacodegen --flask mssql+pymssql://<username>:<password>@<server>/<database> --tables <table_names>> db_name.py

you have to install flask-sqlacodegen and pymssql though.

like image 112
faisal Avatar answered Aug 05 '26 19:08

faisal