SQL Generator#

class besser.generators.sql.sql_generator.SQLGenerator(model: DomainModel, output_dir: str = None, sql_dialect: str = None)[source]#

Bases: GeneratorInterface

SQLGenerator is a class that implements the GeneratorInterface and produces the code or set of SQL statements used to define and modify the structure of the tables in a database..

Parameters:
  • model (DomainModel) – An instance of the DomainModel class representing the B-UML model.

  • output_dir (str, optional) – The output directory where the generated code will be saved. Defaults to None.

  • sql_dialect (str, optional) – The SQL dialect. Values allowed: None, “postgres”, or “mysql”.

TYPES = {'bool': 'bool', 'date': 'date', 'datetime': 'timestamp', 'float': 'float8', 'int': 'int', 'str': 'varchar(100)', 'time': 'time', 'timedelta': 'interval'}#
_abc_impl = <_abc._abc_data object>#
generate()[source]#

Generates SQL code based on the provided B-UML model and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output folder.

Returns:

None, but store the generated code as a file named sql_alchemy.py