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
Raw data
{
"_id": null,
"home_page": "https://gitee.com/summry/sqlx-orm-generator",
"name": "sqlormx-generator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": null,
"keywords": "SQL, sqlormx, python",
"author": "summry",
"author_email": "xiazhongbiao@126.com",
"download_url": "https://files.pythonhosted.org/packages/61/ae/46a54ad97c86bb77fe8edddeabd636de80df11f450265057ce025fad613a/sqlormx_generator-0.1.0.tar.gz",
"platform": null,
"description": "Install\n'''''''\n\n.. code:: shell\n\n pip install sqlormx_generator\n\nUsage Sample\n''''''''''''\n\n.. code:: python\n\n from sqlormx_generator import Generator\n\n if __name__ == '__main__':\n coder = Generator(host='127.0.0.1', port='3306', user='xxx', password='xxx', database='test')\n # you can generate a model class for one table\n coder.generate_with_tables(tables='user', path='models.py')\n # you can generate model classes for tables\n coder.generate_with_tables(tables=['user', 'person'], path='models.py')\n # you can generate model classes for all tables from a given schema. default current schema if not given\n coder.generate_with_schema(schema='test', path='models.py')\n\nIf you run last code, then generate a file 'models.py' in current\ndirectory like follow:\n\n.. code:: python\n\n from decimal import Decimal\n from dataclasses import dataclass\n from datetime import date, datetime\n from sqlormx import Model\n\n @dataclass\n class BaseModel(Model):\n id: int = None\n create_by: int = None\n create_time: datetime = None\n update_by: int = None\n update_time: datetime = None\n del_flag: int = None\n\n\n @dataclass\n class User(BaseModel):\n __table__ = 'user'\n name: str = None\n age: int = None\n birth_date: date = None\n sex: int = None\n\n\nSQLORMX: https://pypi.org/project/sqlormx\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "sqlormx-generator is a model code generator from tables for sqlormx_generator.",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://gitee.com/summry/sqlx-orm-generator"
},
"split_keywords": [
"sql",
" sqlormx",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "61ae46a54ad97c86bb77fe8edddeabd636de80df11f450265057ce025fad613a",
"md5": "1306289d127cea868ff1ef1c9d78c00a",
"sha256": "0e4360f0e88259b9345fb646daaeb70b33edcd68549a9deb45aa5ee0bb9d1ff5"
},
"downloads": -1,
"filename": "sqlormx_generator-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "1306289d127cea868ff1ef1c9d78c00a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 9765,
"upload_time": "2024-07-07T15:20:31",
"upload_time_iso_8601": "2024-07-07T15:20:31.866444Z",
"url": "https://files.pythonhosted.org/packages/61/ae/46a54ad97c86bb77fe8edddeabd636de80df11f450265057ce025fad613a/sqlormx_generator-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-07 15:20:31",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "sqlormx-generator"
}