SQLAlchemy column name with space

There are two ways to resolve this.

  1. When defining the table you would need to specify an alias with the key parameter
t_table_name = Table(
    'tablename',
    metadata,
    Column('SQL Column', Integer, key='sql_column')
)
  1. Define the ORM class as
class Employee(Base):
    emp_name = Column("employee name", String)

Leave a Comment