agronholm / sqlacodegen

Automatic model code generator for SQLAlchemy
Other
1.91k stars 248 forks source link

Add force_class option #348

Open multimeric opened 2 months ago

multimeric commented 2 months ago

The current logic is that, if a table has no primary key, it doesn't use the declarative class generator. However, sqlite has the hidden rowid column which acts as a primary key. For this reason, I want to generate a dataclass and then add rowid as the primary key so that I get all the nice type safety of a dataclass. There are probably also other use cases for ignoring this rule.

Thus, this PR adds a new option called force_class that will generate a dataclass even if there is no obvious primary key.

DevkumarPatel commented 1 month ago

@multimeric when are we expecting this to go to production?.

multimeric commented 1 month ago

I don't follow. You can install directly from my fork if you want.