omymodels


Nameomymodels JSON
Version 0.17.0 PyPI version JSON
download
home_pagehttps://github.com/xnuinside/omymodels
SummaryO! My Models (omymodels) is a library to generate Python Models for SQLAlchemy (ORM & Core), SQLModel, GinoORM, Pydantic, Pydal tables & Python Dataclasses from SQL DDL. And convert one models to another.
upload_time2024-05-12 12:15:19
maintainerNone
docs_urlNone
authorIuliia Volkova
requires_python<4.0,>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
O! My Models
------------


.. image:: https://img.shields.io/pypi/v/omymodels
   :target: https://img.shields.io/pypi/v/omymodels
   :alt: badge1
 
.. image:: https://img.shields.io/pypi/l/omymodels
   :target: https://img.shields.io/pypi/l/omymodels
   :alt: badge2
 
.. image:: https://img.shields.io/pypi/pyversions/omymodels
   :target: https://img.shields.io/pypi/pyversions/omymodels
   :alt: badge3

.. image:: https://github.com/xnuinside/omymodels/actions/workflows/main.yml/badge.svg
   :target: https://github.com/xnuinside/omymodels/actions/workflows/main.yml/badge.svg
   :alt: workflow


Try in Web-UI
-------------

Try the online O!MyModels converter or simply use it online: https://archon-omymodels-online.hf.space/ (A big thanks for that goes to https://github.com/archongum)

Examples
--------

You can find usage examples in the example/ folder on GitHub: https://github.com/xnuinside/omymodels/tree/main/example

About library
-------------

O! My Models (omymodels) is a library that allow you to **generate** different ORM & pure Python models from SQL DDL or **convert** one models type to another (exclude SQLAlchemy Table, it does not supported yet by py-models-parser).

Supported Models:


* SQLAlchemy (https://docs.sqlalchemy.org/en/14/orm/), 
* SQLAlchemy Core (Tables) (https://docs.sqlalchemy.org/en/14/core/metadata.html#accessing-tables-and-columns),
* GinoORM (https://python-gino.org/), 
* Pydantic (https://pydantic-docs.helpmanual.io/),
* Python Enum (https://docs.python.org/3/library/enum.html) - generated only from DDL SQL Types,
* Python Dataclasses (dataclasses module) (https://docs.python.org/3/library/dataclasses.html),

How to install
--------------

.. code-block:: bash


       pip install omymodels

How to use
----------

From Python code
^^^^^^^^^^^^^^^^

Create Models from DDL
^^^^^^^^^^^^^^^^^^^^^^

By default method **create_models** generate GinoORM models, to get Pydantic models output use the argument ``models_type='pydantic'`` ('sqlalchemy' for SQLAlchemy models; 'dataclass' for Dataclasses; 'sqlalchemy_core' for Sqlalchemy Core Tables).

A lot of examples in tests/ - https://github.com/xnuinside/omymodels/tree/main/tests.

For example,

.. code-block:: python

   from omymodels import create_models


   ddl = """
   CREATE table user_history (
        runid                 decimal(21) null
       ,job_id                decimal(21)  null
       ,id                    varchar(100) not null
       ,user              varchar(100) not null
       ,status                varchar(10) not null
       ,event_time            timestamp not null default now()
       ,comment           varchar(1000) not null default 'none'
       ) ;


   """
   result = create_models(ddl, models_type='pydantic')['code']

    # and output will be:    
   import datetime
   from typing import Optional
   from pydantic import BaseModel


   class UserHistory(BaseModel):

       runid: Optional[int]
       job_id: Optional[int]
       id: str
       user: str
       status: str
       event_time: datetime.datetime
       comment: str

To generate Dataclasses from DDL use argument ``models_type='dataclass'``

for example:

.. code-block:: python

       #  (same DDL as in Pydantic sample)
       result = create_models(ddl, schema_global=False, models_type='dataclass')['code']

       # and result will be: 
       import datetime
       from dataclasses import dataclass


       @dataclass
       class UserHistory:

           id: str
           user: str
           status: str
           runid: int = None
           job_id: int = None
           event_time: datetime.datetime = datetime.datetime.now()
           comment: str = 'none'

GinoORM example. If you provide an input like:

.. code-block:: sql


   CREATE TABLE "users" (
     "id" SERIAL PRIMARY KEY,
     "name" varchar,
     "created_at" timestamp,
     "updated_at" timestamp,
     "country_code" int,
     "default_language" int
   );

   CREATE TABLE "languages" (
     "id" int PRIMARY KEY,
     "code" varchar(2) NOT NULL,
     "name" varchar NOT NULL
   );

and you will get output:

.. code-block:: python


       from gino import Gino


       db = Gino()


       class Users(db.Model):

           __tablename__ = 'users'

           id = db.Column(db.Integer(), autoincrement=True, primary_key=True)
           name = db.Column(db.String())
           created_at = db.Column(db.TIMESTAMP())
           updated_at = db.Column(db.TIMESTAMP())
           country_code = db.Column(db.Integer())
           default_language = db.Column(db.Integer())


       class Languages(db.Model):

           __tablename__ = 'languages'

           id = db.Column(db.Integer(), primary_key=True)
           code = db.Column(db.String(2))
           name = db.Column(db.String())

From cli
~~~~~~~~

.. code-block:: bash


       omm path/to/your.ddl

       # for example
       omm tests/test_two_tables.sql

You can define target path where to save models with **-t**\ , **--target** flag:

.. code-block:: bash


       # for example
       omm tests/test_two_tables.sql -t test_path/test_models.py

If you want generate the Pydantic or Dataclasses models - just use flag **-m** or **--models_type='pydantic'** / **--models_type='dataclass'**

.. code-block:: bash


       omm /path/to/your.ddl -m dataclass

       # or 
       omm /path/to/your.ddl --models_type pydantic

Small library is used for parse DDL- https://github.com/xnuinside/simple-ddl-parser.

What to do if types not supported in O!MyModels and you cannot wait until PR will be approved
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

First of all, to parse types correct from DDL to models - they must be in types mypping, for Gino it exitst in this file:

omymodels/gino/types.py  **types_mapping**

If you need to use fast type that not exist in mapping - just do a path before call code with types_mapping.update()

for example:

.. code-block:: python


       from omymodels.models.gino import types
       from omymodels import create_models

       types.types_mapping.update({'your_type_from_ddl': 'db.TypeInGino'})

       ddl = "YOUR DDL with your custom your_type_from_ddl"

       models = create_models(ddl)

       #### And similar for Pydantic types

       from omymodels.models.pydantic import types  types_mapping
       from omymodels import create_models

       types.types_mapping.update({'your_type_from_ddl': 'db.TypeInGino'})

       ddl = "YOUR DDL with your custom your_type_from_ddl"

       models = create_models(ddl, models_type='pydantic')

Schema defenition
^^^^^^^^^^^^^^^^^

There is 2 ways how to define schema in Models:

1) Globally in Gino() class and it will be like this:

.. code-block:: python


       from gino import Gino
       db = Gino(schema="schema_name")

And this is a default way for put schema during generation - it takes first schema in tables and use it. 

2) But if you work with tables in different schemas, you need to define schema in each model in table_args. O!MyModels can do this also. Just use flag ``--no-global-schema`` if you use cli or put argument 'schema_global=False' to create_models() function if you use library from code. Like this:

.. code-block:: python


       ddl = """
       CREATE TABLE "prefix--schema-name"."table" (
       _id uuid PRIMARY KEY,
       one_more_id int
       );
           create unique index table_pk on "prefix--schema-name"."table" (one_more_id) ;
           create index table_ix2 on "prefix--schema-name"."table" (_id) ;
       """
       result = create_models(ddl, schema_global=False)

And result will be this:

.. code-block:: python


       from sqlalchemy.dialects.postgresql import UUID
       from sqlalchemy.schema import UniqueConstraint
       from sqlalchemy import Index
       from gino import Gino

       db = Gino()


       class Table(db.Model):

           __tablename__ = 'table'

           _id = db.Column(UUID, primary_key=True)
           one_more_id = db.Column(db.Integer())

           __table_args__ = (

           UniqueConstraint(one_more_id, name='table_pk'),
           Index('table_ix2', _id),
           dict(schema="prefix--schema-name")
                   )

TODO in next releases
---------------------


#. Add Sequence generation in Models (Gino, SQLAlchemy)
#. Add support for pure Python Classes (https://docs.python.org/3/tutorial/classes.html#class-objects)
#. Add support for Tortoise ORM (https://tortoise-orm.readthedocs.io/en/latest/),
#. Add support for DjangoORM Models
#. Add support for Pydal Models
#. Add support for Encode/orm Models

How to contribute
-----------------

Please describe issue that you want to solve and open the PR, I will review it as soon as possible.

Any questions? Ping me in Telegram: https://t.me/xnuinside or mail xnuinside@gmail.com

If you see any bugs or have any suggestions - feel free to open the issue. Any help will be appritiated.

Appretiation & thanks
---------------------

One more time, big 'thank you!' goes to https://github.com/archongum for Web-version: https://archon-omymodels-online.hf.space/ 

Changelog
---------

**v0.17.0**

Updates
^^^^^^^


#. fix character varying type - https://github.com/xnuinside/omymodels/issues/59
#. sqlalchemy import removed from generation in sqlmodels if it is not used
#. = Field() - is not placed in SQLModel if there is no defaults or other settings to the field

**v0.16.0**

Updates
^^^^^^^


#. Initial SQLModel Support

**v0.15.1**

Updates
-------


#. Foreign Key processing updates - https://github.com/xnuinside/omymodels/pull/55
#. Move to simple-ddl-parser version 1.X

**v0.14.0**

Updates
-------


#. Python 3.11 support. 

**v0.13.0**

New feature
-----------


#. Added argument 'schema_global=' to support SQLAlchemy & Gino different table schemas https://github.com/xnuinside/omymodels/issues/41

**v0.12.1**

Improvements
^^^^^^^^^^^^


#. current_timestamp function processed now same was as "now()" function from ddl

**v0.12.0**

Fixes
^^^^^


#. Now named arguments always went after positional. Fix for https://github.com/xnuinside/omymodels/issues/35

New feature:
^^^^^^^^^^^^


#. Availability to disable auto-name convertion - https://github.com/xnuinside/omymodels/issues/36. 
   Now, if you want to keep names 1-to-1 as in your DDL file, you can set argument ``no_auto_snake_case=True`` and O!MyModels will do nothing with the table or column names.

**v0.11.1**

Improvements:
^^^^^^^^^^^^^


#. added bytes type to pydantic - https://github.com/xnuinside/omymodels/pull/31
#. parser version updated to the latest 

**v0.11.0**

Fixes:
^^^^^^


#. MSSQL column & tables names in [] now is parsed validly  - https://github.com/xnuinside/omymodels/issues/28
#. names like 'users_WorkSchedule' now converted correctly to PascalCase like UsersWorkSchedule

**v0.10.1**


#. Update simple-ddl-parser version to 0.21.2

**v0.10.0**

Improvements:
^^^^^^^^^^^^^


#. Meta models moved to separate package - https://github.com/xnuinside/table-meta
#. ``common`` module renamed to ``from_ddl``\ , but anyway please use public API as imports from main module:

``from omymodels import create_models`` or ``from omymodels import convert_models``

Fixes:
^^^^^^


#. Fixed bunch of bugs in converter, but it stil in 'beta'.
#. Previously you can generate models if was any tables in ddl. Now you can also generate Enum models if in ddl you have only CREATE TYPE statements.
#. String enums now in any models types will be inherit from (str, Enum)

Features:
^^^^^^^^^


#. Added converter feature to convert one model type to another (excluding SQLAlchemy Core (Tables)). 
   Now with more tests for supported models, but still in Beta with bucnh of issues.

**v0.9.0**
Features:


#. Added beta models converter from one type of models to another.
   To use models convertor:

.. code-block:: python

   from omymodels import convert_models


   models_from = """

   class MaterialType(str, Enum):

       article = "article"
       video = "video"


   @dataclass
   class Material:

       id: int
       title: str
       description: str
       link: str
       type: MaterialType
       additional_properties: Union[dict, list]
       created_at: datetime.datetime
       updated_at: datetime.datetime

   """

   result = convert_models(models_from, models_type="gino")
   print(result)

where ``models_type`` - type of models that you want to get as a result


#. Now if O!MyModels does not know how to convert type - he just leave it as is.

Fixes:


#. In Dataclass & Pydantic generators now Decimals & Floats converted to float (previously was int).

**v0.8.4**


#. Now if tables was not found in input DDL - models generator raise NoTable error. if you want to have still silent exit if no tables, please use flag: exit_silent

**v0.8.3**


#. Added fundamental concept of TableMetaModel - class that unifies metadata parsed from different classes/ORM models types/DDLs to one standard to allow easy way convert one models to another
   in next releases it will be used for converter from one type of models to another.
#. Fixed issue: https://github.com/xnuinside/omymodels/issues/18 "NOW() not recognized as now()"
#. Fixed issue: https://github.com/xnuinside/omymodels/issues/19 "Default value of now() always returns same time, use field for dataclass"

**v0.8.1**


#. Parser version is updated (fixed several issues with generation)
#. Fixed issue with Unique Constraint after schema in SQLAlchemy Core

**v0.8.0**


#. Fix --defaults-off flag in cli
#. Added support for SQLAlchemy Core Tables generating
#. Added examples folder in github ``omymodels/example``
#. Fix issue with ForeignKey in SQLAlchemy

**v0.7.0**


#. Added generation for SQLAlchemy models (defaults from DDLs are setting up as 'server_default')
#. Added defaults for Pydantic models
#. Added flag to generate Pydantic & Dataclass models WITHOUT defaults ``defaults_off=True`` (by default it is False). And cli flag --defaults-off
#. Fixed issue with Enum types with lower case names in DDLs
#. Fixed several issues with Dataclass generation (default with datetime & Enums)
#. '"' do not remove from defaults now

**v0.6.0**


#. O!MyModels now also can generate python Dataclass from DDL. Use argument models_type='dataclass' or if you use the cli flag --models_type dataclass or -m dataclass
#. Added ForeignKey generation to GinoORM Models, added support for ondelete and onupdate

**v0.5.0**


#. Added Enums/IntEnums types for Gino & Pydantic
#. Added UUID type
#. Added key ``schema_global`` in create_models method (by default schema_global = True). 
   If you set schema_global=False schema if it exists in ddl will be defined for each table (model) in table args.
   This way you can have differen schemas per model (table). By default schema_global=True - this mean for all 
   table only one schema and it is defined in ``db = Gino(schema="prefix--schema-name")``.
#. If column is a primary key (primary_key=True) nullable argument not showed, because primary keys always are not null.
#. To cli was added flag '--no-global-schema' to set schema in table_args.

**v0.4.1**


#. Added correct work with table names contains multiple '-'

**v0.4.0**


#. Added generation for Pydantic models from ddl
#. Main method create_gino_models renamed to create_models

**v0.3.0**


#. Generated Index for 'index' statement in **table_args** (not unique constrait as previously)
#. Fix issue with column size as tuple (4,2)

**v0.2.0**


#. Valid generating columns in models: autoincrement, default, type, arrays, unique, primary key and etc.
#. Added creating **table_args** for indexes

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xnuinside/omymodels",
    "name": "omymodels",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Iuliia Volkova",
    "author_email": "xnuinside@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/97/3b/35c63ef50f886e7d934fb73f9e2e79e00b79bdcb19aa9ad0c5a96c03a417/omymodels-0.17.0.tar.gz",
    "platform": null,
    "description": "\nO! My Models\n------------\n\n\n.. image:: https://img.shields.io/pypi/v/omymodels\n   :target: https://img.shields.io/pypi/v/omymodels\n   :alt: badge1\n \n.. image:: https://img.shields.io/pypi/l/omymodels\n   :target: https://img.shields.io/pypi/l/omymodels\n   :alt: badge2\n \n.. image:: https://img.shields.io/pypi/pyversions/omymodels\n   :target: https://img.shields.io/pypi/pyversions/omymodels\n   :alt: badge3\n\n.. image:: https://github.com/xnuinside/omymodels/actions/workflows/main.yml/badge.svg\n   :target: https://github.com/xnuinside/omymodels/actions/workflows/main.yml/badge.svg\n   :alt: workflow\n\n\nTry in Web-UI\n-------------\n\nTry the online O!MyModels converter or simply use it online: https://archon-omymodels-online.hf.space/ (A big thanks for that goes to https://github.com/archongum)\n\nExamples\n--------\n\nYou can find usage examples in the example/ folder on GitHub: https://github.com/xnuinside/omymodels/tree/main/example\n\nAbout library\n-------------\n\nO! My Models (omymodels) is a library that allow you to **generate** different ORM & pure Python models from SQL DDL or **convert** one models type to another (exclude SQLAlchemy Table, it does not supported yet by py-models-parser).\n\nSupported Models:\n\n\n* SQLAlchemy (https://docs.sqlalchemy.org/en/14/orm/), \n* SQLAlchemy Core (Tables) (https://docs.sqlalchemy.org/en/14/core/metadata.html#accessing-tables-and-columns),\n* GinoORM (https://python-gino.org/), \n* Pydantic (https://pydantic-docs.helpmanual.io/),\n* Python Enum (https://docs.python.org/3/library/enum.html) - generated only from DDL SQL Types,\n* Python Dataclasses (dataclasses module) (https://docs.python.org/3/library/dataclasses.html),\n\nHow to install\n--------------\n\n.. code-block:: bash\n\n\n       pip install omymodels\n\nHow to use\n----------\n\nFrom Python code\n^^^^^^^^^^^^^^^^\n\nCreate Models from DDL\n^^^^^^^^^^^^^^^^^^^^^^\n\nBy default method **create_models** generate GinoORM models, to get Pydantic models output use the argument ``models_type='pydantic'`` ('sqlalchemy' for SQLAlchemy models; 'dataclass' for Dataclasses; 'sqlalchemy_core' for Sqlalchemy Core Tables).\n\nA lot of examples in tests/ - https://github.com/xnuinside/omymodels/tree/main/tests.\n\nFor example,\n\n.. code-block:: python\n\n   from omymodels import create_models\n\n\n   ddl = \"\"\"\n   CREATE table user_history (\n        runid                 decimal(21) null\n       ,job_id                decimal(21)  null\n       ,id                    varchar(100) not null\n       ,user              varchar(100) not null\n       ,status                varchar(10) not null\n       ,event_time            timestamp not null default now()\n       ,comment           varchar(1000) not null default 'none'\n       ) ;\n\n\n   \"\"\"\n   result = create_models(ddl, models_type='pydantic')['code']\n\n    # and output will be:    \n   import datetime\n   from typing import Optional\n   from pydantic import BaseModel\n\n\n   class UserHistory(BaseModel):\n\n       runid: Optional[int]\n       job_id: Optional[int]\n       id: str\n       user: str\n       status: str\n       event_time: datetime.datetime\n       comment: str\n\nTo generate Dataclasses from DDL use argument ``models_type='dataclass'``\n\nfor example:\n\n.. code-block:: python\n\n       #  (same DDL as in Pydantic sample)\n       result = create_models(ddl, schema_global=False, models_type='dataclass')['code']\n\n       # and result will be: \n       import datetime\n       from dataclasses import dataclass\n\n\n       @dataclass\n       class UserHistory:\n\n           id: str\n           user: str\n           status: str\n           runid: int = None\n           job_id: int = None\n           event_time: datetime.datetime = datetime.datetime.now()\n           comment: str = 'none'\n\nGinoORM example. If you provide an input like:\n\n.. code-block:: sql\n\n\n   CREATE TABLE \"users\" (\n     \"id\" SERIAL PRIMARY KEY,\n     \"name\" varchar,\n     \"created_at\" timestamp,\n     \"updated_at\" timestamp,\n     \"country_code\" int,\n     \"default_language\" int\n   );\n\n   CREATE TABLE \"languages\" (\n     \"id\" int PRIMARY KEY,\n     \"code\" varchar(2) NOT NULL,\n     \"name\" varchar NOT NULL\n   );\n\nand you will get output:\n\n.. code-block:: python\n\n\n       from gino import Gino\n\n\n       db = Gino()\n\n\n       class Users(db.Model):\n\n           __tablename__ = 'users'\n\n           id = db.Column(db.Integer(), autoincrement=True, primary_key=True)\n           name = db.Column(db.String())\n           created_at = db.Column(db.TIMESTAMP())\n           updated_at = db.Column(db.TIMESTAMP())\n           country_code = db.Column(db.Integer())\n           default_language = db.Column(db.Integer())\n\n\n       class Languages(db.Model):\n\n           __tablename__ = 'languages'\n\n           id = db.Column(db.Integer(), primary_key=True)\n           code = db.Column(db.String(2))\n           name = db.Column(db.String())\n\nFrom cli\n~~~~~~~~\n\n.. code-block:: bash\n\n\n       omm path/to/your.ddl\n\n       # for example\n       omm tests/test_two_tables.sql\n\nYou can define target path where to save models with **-t**\\ , **--target** flag:\n\n.. code-block:: bash\n\n\n       # for example\n       omm tests/test_two_tables.sql -t test_path/test_models.py\n\nIf you want generate the Pydantic or Dataclasses models - just use flag **-m** or **--models_type='pydantic'** / **--models_type='dataclass'**\n\n.. code-block:: bash\n\n\n       omm /path/to/your.ddl -m dataclass\n\n       # or \n       omm /path/to/your.ddl --models_type pydantic\n\nSmall library is used for parse DDL- https://github.com/xnuinside/simple-ddl-parser.\n\nWhat to do if types not supported in O!MyModels and you cannot wait until PR will be approved\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nFirst of all, to parse types correct from DDL to models - they must be in types mypping, for Gino it exitst in this file:\n\nomymodels/gino/types.py  **types_mapping**\n\nIf you need to use fast type that not exist in mapping - just do a path before call code with types_mapping.update()\n\nfor example:\n\n.. code-block:: python\n\n\n       from omymodels.models.gino import types\n       from omymodels import create_models\n\n       types.types_mapping.update({'your_type_from_ddl': 'db.TypeInGino'})\n\n       ddl = \"YOUR DDL with your custom your_type_from_ddl\"\n\n       models = create_models(ddl)\n\n       #### And similar for Pydantic types\n\n       from omymodels.models.pydantic import types  types_mapping\n       from omymodels import create_models\n\n       types.types_mapping.update({'your_type_from_ddl': 'db.TypeInGino'})\n\n       ddl = \"YOUR DDL with your custom your_type_from_ddl\"\n\n       models = create_models(ddl, models_type='pydantic')\n\nSchema defenition\n^^^^^^^^^^^^^^^^^\n\nThere is 2 ways how to define schema in Models:\n\n1) Globally in Gino() class and it will be like this:\n\n.. code-block:: python\n\n\n       from gino import Gino\n       db = Gino(schema=\"schema_name\")\n\nAnd this is a default way for put schema during generation - it takes first schema in tables and use it. \n\n2) But if you work with tables in different schemas, you need to define schema in each model in table_args. O!MyModels can do this also. Just use flag ``--no-global-schema`` if you use cli or put argument 'schema_global=False' to create_models() function if you use library from code. Like this:\n\n.. code-block:: python\n\n\n       ddl = \"\"\"\n       CREATE TABLE \"prefix--schema-name\".\"table\" (\n       _id uuid PRIMARY KEY,\n       one_more_id int\n       );\n           create unique index table_pk on \"prefix--schema-name\".\"table\" (one_more_id) ;\n           create index table_ix2 on \"prefix--schema-name\".\"table\" (_id) ;\n       \"\"\"\n       result = create_models(ddl, schema_global=False)\n\nAnd result will be this:\n\n.. code-block:: python\n\n\n       from sqlalchemy.dialects.postgresql import UUID\n       from sqlalchemy.schema import UniqueConstraint\n       from sqlalchemy import Index\n       from gino import Gino\n\n       db = Gino()\n\n\n       class Table(db.Model):\n\n           __tablename__ = 'table'\n\n           _id = db.Column(UUID, primary_key=True)\n           one_more_id = db.Column(db.Integer())\n\n           __table_args__ = (\n\n           UniqueConstraint(one_more_id, name='table_pk'),\n           Index('table_ix2', _id),\n           dict(schema=\"prefix--schema-name\")\n                   )\n\nTODO in next releases\n---------------------\n\n\n#. Add Sequence generation in Models (Gino, SQLAlchemy)\n#. Add support for pure Python Classes (https://docs.python.org/3/tutorial/classes.html#class-objects)\n#. Add support for Tortoise ORM (https://tortoise-orm.readthedocs.io/en/latest/),\n#. Add support for DjangoORM Models\n#. Add support for Pydal Models\n#. Add support for Encode/orm Models\n\nHow to contribute\n-----------------\n\nPlease describe issue that you want to solve and open the PR, I will review it as soon as possible.\n\nAny questions? Ping me in Telegram: https://t.me/xnuinside or mail xnuinside@gmail.com\n\nIf you see any bugs or have any suggestions - feel free to open the issue. Any help will be appritiated.\n\nAppretiation & thanks\n---------------------\n\nOne more time, big 'thank you!' goes to https://github.com/archongum for Web-version: https://archon-omymodels-online.hf.space/ \n\nChangelog\n---------\n\n**v0.17.0**\n\nUpdates\n^^^^^^^\n\n\n#. fix character varying type - https://github.com/xnuinside/omymodels/issues/59\n#. sqlalchemy import removed from generation in sqlmodels if it is not used\n#. = Field() - is not placed in SQLModel if there is no defaults or other settings to the field\n\n**v0.16.0**\n\nUpdates\n^^^^^^^\n\n\n#. Initial SQLModel Support\n\n**v0.15.1**\n\nUpdates\n-------\n\n\n#. Foreign Key processing updates - https://github.com/xnuinside/omymodels/pull/55\n#. Move to simple-ddl-parser version 1.X\n\n**v0.14.0**\n\nUpdates\n-------\n\n\n#. Python 3.11 support. \n\n**v0.13.0**\n\nNew feature\n-----------\n\n\n#. Added argument 'schema_global=' to support SQLAlchemy & Gino different table schemas https://github.com/xnuinside/omymodels/issues/41\n\n**v0.12.1**\n\nImprovements\n^^^^^^^^^^^^\n\n\n#. current_timestamp function processed now same was as \"now()\" function from ddl\n\n**v0.12.0**\n\nFixes\n^^^^^\n\n\n#. Now named arguments always went after positional. Fix for https://github.com/xnuinside/omymodels/issues/35\n\nNew feature:\n^^^^^^^^^^^^\n\n\n#. Availability to disable auto-name convertion - https://github.com/xnuinside/omymodels/issues/36. \n   Now, if you want to keep names 1-to-1 as in your DDL file, you can set argument ``no_auto_snake_case=True`` and O!MyModels will do nothing with the table or column names.\n\n**v0.11.1**\n\nImprovements:\n^^^^^^^^^^^^^\n\n\n#. added bytes type to pydantic - https://github.com/xnuinside/omymodels/pull/31\n#. parser version updated to the latest \n\n**v0.11.0**\n\nFixes:\n^^^^^^\n\n\n#. MSSQL column & tables names in [] now is parsed validly  - https://github.com/xnuinside/omymodels/issues/28\n#. names like 'users_WorkSchedule' now converted correctly to PascalCase like UsersWorkSchedule\n\n**v0.10.1**\n\n\n#. Update simple-ddl-parser version to 0.21.2\n\n**v0.10.0**\n\nImprovements:\n^^^^^^^^^^^^^\n\n\n#. Meta models moved to separate package - https://github.com/xnuinside/table-meta\n#. ``common`` module renamed to ``from_ddl``\\ , but anyway please use public API as imports from main module:\n\n``from omymodels import create_models`` or ``from omymodels import convert_models``\n\nFixes:\n^^^^^^\n\n\n#. Fixed bunch of bugs in converter, but it stil in 'beta'.\n#. Previously you can generate models if was any tables in ddl. Now you can also generate Enum models if in ddl you have only CREATE TYPE statements.\n#. String enums now in any models types will be inherit from (str, Enum)\n\nFeatures:\n^^^^^^^^^\n\n\n#. Added converter feature to convert one model type to another (excluding SQLAlchemy Core (Tables)). \n   Now with more tests for supported models, but still in Beta with bucnh of issues.\n\n**v0.9.0**\nFeatures:\n\n\n#. Added beta models converter from one type of models to another.\n   To use models convertor:\n\n.. code-block:: python\n\n   from omymodels import convert_models\n\n\n   models_from = \"\"\"\n\n   class MaterialType(str, Enum):\n\n       article = \"article\"\n       video = \"video\"\n\n\n   @dataclass\n   class Material:\n\n       id: int\n       title: str\n       description: str\n       link: str\n       type: MaterialType\n       additional_properties: Union[dict, list]\n       created_at: datetime.datetime\n       updated_at: datetime.datetime\n\n   \"\"\"\n\n   result = convert_models(models_from, models_type=\"gino\")\n   print(result)\n\nwhere ``models_type`` - type of models that you want to get as a result\n\n\n#. Now if O!MyModels does not know how to convert type - he just leave it as is.\n\nFixes:\n\n\n#. In Dataclass & Pydantic generators now Decimals & Floats converted to float (previously was int).\n\n**v0.8.4**\n\n\n#. Now if tables was not found in input DDL - models generator raise NoTable error. if you want to have still silent exit if no tables, please use flag: exit_silent\n\n**v0.8.3**\n\n\n#. Added fundamental concept of TableMetaModel - class that unifies metadata parsed from different classes/ORM models types/DDLs to one standard to allow easy way convert one models to another\n   in next releases it will be used for converter from one type of models to another.\n#. Fixed issue: https://github.com/xnuinside/omymodels/issues/18 \"NOW() not recognized as now()\"\n#. Fixed issue: https://github.com/xnuinside/omymodels/issues/19 \"Default value of now() always returns same time, use field for dataclass\"\n\n**v0.8.1**\n\n\n#. Parser version is updated (fixed several issues with generation)\n#. Fixed issue with Unique Constraint after schema in SQLAlchemy Core\n\n**v0.8.0**\n\n\n#. Fix --defaults-off flag in cli\n#. Added support for SQLAlchemy Core Tables generating\n#. Added examples folder in github ``omymodels/example``\n#. Fix issue with ForeignKey in SQLAlchemy\n\n**v0.7.0**\n\n\n#. Added generation for SQLAlchemy models (defaults from DDLs are setting up as 'server_default')\n#. Added defaults for Pydantic models\n#. Added flag to generate Pydantic & Dataclass models WITHOUT defaults ``defaults_off=True`` (by default it is False). And cli flag --defaults-off\n#. Fixed issue with Enum types with lower case names in DDLs\n#. Fixed several issues with Dataclass generation (default with datetime & Enums)\n#. '\"' do not remove from defaults now\n\n**v0.6.0**\n\n\n#. O!MyModels now also can generate python Dataclass from DDL. Use argument models_type='dataclass' or if you use the cli flag --models_type dataclass or -m dataclass\n#. Added ForeignKey generation to GinoORM Models, added support for ondelete and onupdate\n\n**v0.5.0**\n\n\n#. Added Enums/IntEnums types for Gino & Pydantic\n#. Added UUID type\n#. Added key ``schema_global`` in create_models method (by default schema_global = True). \n   If you set schema_global=False schema if it exists in ddl will be defined for each table (model) in table args.\n   This way you can have differen schemas per model (table). By default schema_global=True - this mean for all \n   table only one schema and it is defined in ``db = Gino(schema=\"prefix--schema-name\")``.\n#. If column is a primary key (primary_key=True) nullable argument not showed, because primary keys always are not null.\n#. To cli was added flag '--no-global-schema' to set schema in table_args.\n\n**v0.4.1**\n\n\n#. Added correct work with table names contains multiple '-'\n\n**v0.4.0**\n\n\n#. Added generation for Pydantic models from ddl\n#. Main method create_gino_models renamed to create_models\n\n**v0.3.0**\n\n\n#. Generated Index for 'index' statement in **table_args** (not unique constrait as previously)\n#. Fix issue with column size as tuple (4,2)\n\n**v0.2.0**\n\n\n#. Valid generating columns in models: autoincrement, default, type, arrays, unique, primary key and etc.\n#. Added creating **table_args** for indexes\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "O! My Models (omymodels) is a library to generate Python Models for SQLAlchemy (ORM & Core), SQLModel, GinoORM, Pydantic, Pydal tables & Python Dataclasses from SQL DDL. And convert one models to another.",
    "version": "0.17.0",
    "project_urls": {
        "Homepage": "https://github.com/xnuinside/omymodels",
        "Repository": "https://github.com/xnuinside/omymodels"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a77f9c34c1b2b899f386e3dcb6d08da0f523fc667c13e0cf4c4586325f5ba65",
                "md5": "fff2b7fcc8de22854a82d85d44dc07b8",
                "sha256": "663352c15af8ffeb2037eda16fd0818e013f16ffe9efca639ac49f82722b8dfc"
            },
            "downloads": -1,
            "filename": "omymodels-0.17.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fff2b7fcc8de22854a82d85d44dc07b8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.7",
            "size": 36460,
            "upload_time": "2024-05-12T12:15:17",
            "upload_time_iso_8601": "2024-05-12T12:15:17.040437Z",
            "url": "https://files.pythonhosted.org/packages/9a/77/f9c34c1b2b899f386e3dcb6d08da0f523fc667c13e0cf4c4586325f5ba65/omymodels-0.17.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "973b35c63ef50f886e7d934fb73f9e2e79e00b79bdcb19aa9ad0c5a96c03a417",
                "md5": "43ba4b98a0b2fd65b5192206735ac961",
                "sha256": "d970b8ed293e713a34c351bcd51fb8f2c18776e7ee353748dbe3fd377e7c21f3"
            },
            "downloads": -1,
            "filename": "omymodels-0.17.0.tar.gz",
            "has_sig": false,
            "md5_digest": "43ba4b98a0b2fd65b5192206735ac961",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.7",
            "size": 26780,
            "upload_time": "2024-05-12T12:15:19",
            "upload_time_iso_8601": "2024-05-12T12:15:19.441206Z",
            "url": "https://files.pythonhosted.org/packages/97/3b/35c63ef50f886e7d934fb73f9e2e79e00b79bdcb19aa9ad0c5a96c03a417/omymodels-0.17.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-12 12:15:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xnuinside",
    "github_project": "omymodels",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "omymodels"
}
        
Elapsed time: 0.23509s