Back to directory

sqlmodelgen

A Python library and command-line tool that generates SQLModel model classes from CREATE TABLE statements, a SQLite file, or a Postgres or MySQL connection, optionally inferring relationships from foreign keys.

sqlmodelgen

sqlmodelgen generates Python classes for the sqlmodel library from an existing schema. It accepts direct CREATE TABLE SQL statements, a SQLite file path, a Postgres connection string, or a MySQL connection object from the mysql-connector-python library, and exposes a matching function for each source, such as gen_code_from_sql, gen_code_from_sqlite, gen_code_from_postgres and gen_code_from_mysql.

It installs from PyPI, with separate optional extras for the Postgres and MySQL sources so their driver dependencies are not required for the base SQLite and raw-SQL cases. It can be used both as a command-line tool and as a library called from Python code.

Passing generate_relationships=True to any of the generator functions makes sqlmodelgen also infer and generate relationships between the produced classes based on the foreign keys found in the source schema.

More in Databases

See all 294
  • SQLBraid

    clickin.github.io

    A SQL-first data-access toolkit for TypeScript that keeps ordinary SQL visible in tagged template literals, binds interpolated values safely by default, supports readable conditional SQL directives, and lets a schema validate the returned rows.

  • A SQL-style query language and toolchain for the Qdrant vector database, covering dense, sparse and hybrid search, filtering and multitenancy, with the same grammar running from a CLI, Python, Node.js, Rust, WebAssembly and an in-process edge engine.

  • Fast Knowledge

    github.com

    A self-hosted, Java-based knowledge base for small and mid-sized organizations, turning internal documents into a searchable, question-answerable and audit-exportable knowledge asset with hybrid retrieval and Docker deployment.