Reputation: 11
I am trying to create tables in mysql with flask-sqlalchemy. My problem is that the classnames always start with capital letters while I would like to create all tables with lowercase.
Is there a way to fix that? I read that the default behaviour of the flask-sqlalchemy is converting it to lowercase, but it does not seem to work for me.
Thanks for any advice :)
Upvotes: 1
Views: 1107
Reputation: 1431
the default should mape class Name to table 'name'. now I'm curious why your code doesn't. I recently thought my code was not creating the correct tablename only to discover it wasn'it initalising the database correctly due to omitting the database initialisation in my flask server configuration.
https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/table_config.html https://docs.sqlalchemy.org/en/13/orm/mapping_columns.html
Upvotes: 1
Reputation: 3864
You can manually define your table names on your models with __tablename__
property.
Upvotes: 1