ponyorm / pony

Pony Object Relational Mapper
Apache License 2.0
3.63k stars 245 forks source link

Database property to check if mapping has been generated #716

Open ssimo3lsuhsc opened 3 months ago

ssimo3lsuhsc commented 3 months ago

Could I request that the Database class expose a property Mapped: bool that holds the property that the database has been mapped? One exception is generated if the user tries to construct a db_session without generating a mapping; however, another exception is thrown if the method Database.generate_mapping() is called more than once on a single Database instance. I constantly have to remember in which file I generated the mapping, and so I believe that it is better to always in principle check if a mapping has been generated in the header of any file in which I use Pony entities.