Install '''''''
.. code:: shell
pip install pgsqlx-generator
Usage Sample ''''''''''''
.. code:: python
from pgsqlx.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 datetime import date, datetime
from pgsqlx.orm import Model, PkStrategy
class BaseModel(Model):
__pk__ = 'id'
__del_flag__ = 'del_flag'
__update_by__ = 'update_by'
__update_time__ = 'update_time'
__pk_strategy__ = PkStrategy.DB_AUTO_INCREMENT
def __init__(self, id: int = None, create_by: int = None, create_time: datetime = None, update_by: int = None, update_time: datetime = None,
del_flag: int = None):
self.id = id
self.create_by = create_by
self.create_time = create_time
self.update_by = update_by
self.update_time = update_time
self.del_flag = del_flag
class Person(BaseModel):
__table__ = 'person'
__key_seq__ = 'person_id_seq'
def __init__(self, id: int = None, name: str = None, age: int = None, birth_date: date = None, sex: int = None, grade: float = None,
point: float = None, money: Decimal = None, create_by: int = None, create_time: datetime = None, update_by: int = None,
update_time: datetime = None, del_flag: int = None):
super().__init__(id=id, create_by=create_by, create_time=create_time, update_by=update_by, update_time=update_time, del_flag=del_flag)
self.name = name
self.age = age
self.birth_date = birth_date
self.sex = sex
self.grade = grade
self.point = point
self.money = money
PgSqlx: https://pypi.org/project/pgsqlx
Metadata
Release files for pgsqlx-generator 1.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pgsqlx-generator-1.7.4.tar.gz | 5.3 kB | Without provenance | Details for pgsqlx-generator-1.7.4.tar.gz |
Release files / pgsqlx-generator-1.7.4.tar.gz
| Download URL | pgsqlx-generator-1.7.4.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d156cffc17edc8f7e4678f99de9f92a8c5a5529d876ec101ad24f1f38675f09
|
|
BLAKE2b-256 checksum How to use checksums |
c666e41a4efdd0eb2b1ae7f853b18c144bd4de01c239f42db5305b03b23949da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.10
|
Security for pgsqlx-generator 1.7.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.