scripts.airtable.generate_schema

Writes api/integrations/airtable/schema.py from the structure of the base in .env.

Each table becomes a pyAirtable ORM model with typed fields (unit.prix_de_vente_ht), plus the names the dictionary-based code still uses: TABLE and one constant per field (ToutesLesUnites.PRIX_DE_VENTE_HT == “Prix de vente HT”). Field types come from pyAirtable’s own generator; names are transliterated (“Numéro de série” -> numero_de_serie) and made unique.

Run it against the production base after a change in Airtable (make airtable-schema): the git diff shows what changed, and mypy then flags code that uses a field that no longer exists. The token needs the schema.bases:read scope.

Attributes

Functions

constant_name(name) → str

'Prix de vente HT' -> PRIX_DE_VENTE_HT.

attribute_name(name) → str

'Numéro de série' -> numero_de_serie.

class_name(name) → str

'Toutes les unités' -> ToutesLesUnites.

render(file_builder, base_id, today) → str

The module's code: one ORM class per table of file_builder, sorted by name.

main() → int

Module Contents

scripts.airtable.generate_schema.RESERVED
scripts.airtable.generate_schema.COMPUTED
scripts.airtable.generate_schema.TARGET
scripts.airtable.generate_schema.constant_name(name: str) → str

‘Prix de vente HT’ -> PRIX_DE_VENTE_HT.

scripts.airtable.generate_schema.attribute_name(name: str) → str

‘Numéro de série’ -> numero_de_serie.

scripts.airtable.generate_schema.class_name(name: str) → str

‘Toutes les unités’ -> ToutesLesUnites.

scripts.airtable.generate_schema.render(file_builder: pyairtable.orm.generate.ModelFileBuilder, base_id: str, today: datetime.date) → str

The module’s code: one ORM class per table of file_builder, sorted by name.

scripts.airtable.generate_schema.main() → int