Skip to main content

sqlormx-generator is a model code generator from tables for sqlormx_generator.

Project description

Install '''''''

.. code:: shell

pip install sqlormx_generator

Usage Sample ''''''''''''

.. code:: python

   from sqlormx_generator import Generator

   if __name__ == '__main__':
       coder = Generator(host='127.0.0.1', port='3306', user='xxx', password='xxx', database='test')
       # you can generate a model class for one table
       coder.generate_with_tables(tables='user', path='models.py')
       # you can generate model classes for tables
       coder.generate_with_tables(tables=['user', 'person'], path='models.py')
       # you can generate model classes for all tables from a given schema. default current schema if not given
       coder.generate_with_schema(schema='test', path='models.py')

If you run last code, then generate a file 'models.py' in current directory like follow:

.. code:: python

   from decimal import Decimal
   from dataclasses import dataclass
   from datetime import date, datetime
   from sqlormx import Model

   @dataclass
   class BaseModel(Model):
       id: int = None
       create_by: int = None
       create_time: datetime = None
       update_by: int = None
       update_time: datetime = None
       del_flag: int = None


   @dataclass
   class User(BaseModel):
       __table__ = 'user'
       name: str = None
       age: int = None
       birth_date: date = None
       sex: int = None

SQLORMX: https://pypi.org/project/sqlormx

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlormx_generator-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file sqlormx_generator-0.1.0.tar.gz.

File metadata

  • Download URL: sqlormx_generator-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for sqlormx_generator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e4360f0e88259b9345fb646daaeb70b33edcd68549a9deb45aa5ee0bb9d1ff5
MD5 1306289d127cea868ff1ef1c9d78c00a
BLAKE2b-256 61ae46a54ad97c86bb77fe8edddeabd636de80df11f450265057ce025fad613a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page