One of many tables in SQL Server database has far more columns than I need, upwards of 40-50, and I only need 5 or 6 of them. Can I map only the columns I need?
2
Yes.
From docs.sqlalchemy.org
Sometimes, a Table object was made available using the reflection process described at Reflecting Database Objects to load the table’s structure from the database. For such a table that has lots of columns that don’t need to be referenced in the application, the include_properties or exclude_properties arguments can specify that only a subset of columns should be mapped.
2
You don’t need to map every column from your MSSQL database in SQLAlchemy. You can map only the columns you need by specifying them in your model. It will only interact with the columns defined in your model.
1
Short answer: Yes, you can.
For such a table that has lots of columns
that don’t need to be referenced in the application, the
include_properties
orexclude_properties
arguments can specify that
only a subset of columns should be mapped
Read more details on SQLAlchemy docs