python - Length Limit for MySQL Identifiers (table names, column names) using SQLAlchemy with Elixir -
i using sqlalchemy elixir , works fine using sqlite. however, when switch mysql there table name , column name length limit (64 characters). have quite lot of entities several manytomany relationships , did not find way clamp resulting long table names myfirstentity_rel_otherentities__mysecondentity_rel_thefirstentities
in automated way.
foreign key column names manytoone relationships long depending on class , relation name. create_engine("...", label_length = 64)
did not trick , use shortcolumns = true
avoid having entire python module name prefix well.
the way see go through whole schema , define tablename (for manytomany relationships) , columnname (for manytoone relationships) manually. there other other options?
yes, there more automatic solution: update default elixir options tablename re-definition:
elixir.options_defaults.update( dict( tablename = lambda cls: cls.__name__.lower() ) )
this cause tables referred short names (ie, model name only).
It's an honor to read good quality content like you have written here. You have proven your true writing talent and presented your views well. elixir definition Define Dictionary Meaning. A simple vocabulary sharing platform. Dedicated to learn and share knowledge by defining words and concepts in short and easy English. Define your own words and their meanings.
ReplyDelete