diff options
author | CoprDistGit <infra@openeuler.org> | 2023-04-11 23:07:47 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-04-11 23:07:47 +0000 |
commit | 8e37aaef7ee02db5b489722cd1baf926193b98a7 (patch) | |
tree | 1b4a3fbc17a9c2a1053003799916ff4db50a1c06 /python-pydbml.spec | |
parent | 9b0f7454948c3ef6681ea46a1b0a487cb7b707ed (diff) |
automatic import of python-pydbml
Diffstat (limited to 'python-pydbml.spec')
-rw-r--r-- | python-pydbml.spec | 538 |
1 files changed, 538 insertions, 0 deletions
diff --git a/python-pydbml.spec b/python-pydbml.spec new file mode 100644 index 0000000..0e2ee83 --- /dev/null +++ b/python-pydbml.spec @@ -0,0 +1,538 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pydbml +Version: 1.0.7 +Release: 1 +Summary: Python parser and builder for DBML +License: MIT +URL: https://github.com/Vanderhoof/PyDBML +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/de/37/2ae760ecd61488091a4b354db664aec1ecf30d60fcd5c6fb5d5643be5224/pydbml-1.0.7.tar.gz +BuildArch: noarch + +Requires: python3-pyparsing + +%description +[](https://pypi.org/project/pydbml/) [](https://pypi.org/project/pydbml/) [](https://github.com/Vanderhoof/PyDBML)  + +# DBML parser for Python + +*Compliant with DBML **v2.4.4** syntax* + +PyDBML is a Python parser and builder for [DBML](https://www.dbml.org) syntax. + +> The project was rewritten in May 2022, the new version 1.0.0 is not compatible with the previous ones. See details in [Upgrading to PyDBML 1.0.0](docs/upgrading.md). + +**Docs:** + +* [Class Reference](docs/classes.md) +* [Creating DBML schema](docs/creating_schema.md) +* [Upgrading to PyDBML 1.0.0](docs/upgrading.md) + +> PyDBML requires Python v3.8 or higher + +## Installation + +You can install PyDBML using pip: + +```bash +pip3 install pydbml +``` + +## Quick start + +To parse a DBML file, import the `PyDBML` class and initialize it with Path object + +```python +>>> from pydbml import PyDBML +>>> from pathlib import Path +>>> parsed = PyDBML(Path('test_schema.dbml')) + +``` + +or with file stream + +```python +>>> with open('test_schema.dbml') as f: +... parsed = PyDBML(f) + +``` + +or with entire source string + +```python +>>> with open('test_schema.dbml') as f: +... source = f.read() +>>> parsed = PyDBML(source) +>>> parsed +<Database> + +``` + +The parser returns a Database object that is a container for the parsed DBML entities. + +You can access tables inside the `tables` attribute: + +```python +>>> for table in parsed.tables: +... print(table.name) +... +orders +order_items +products +users +merchants +countries + +``` + +Or just by getting items by index or full table name: + +```python +>>> parsed[1] +<Table 'public' 'order_items'> +>>> parsed['public.countries'] +<Table 'public' 'countries'> + +``` + +Other attributes are: + +* **refs** — list of all references, +* **enums** — list of all enums, +* **table_groups** — list of all table groups, +* **project** — the Project object, if was defined. + +Generate SQL for your DBML Database by accessing the `sql` property: + +```python +>>> print(parsed.sql) # doctest:+ELLIPSIS +CREATE TYPE "orders_status" AS ENUM ( + 'created', + 'running', + 'done', + 'failure', +); +<BLANKLINE> +CREATE TYPE "product status" AS ENUM ( + 'Out of Stock', + 'In Stock', +); +<BLANKLINE> +CREATE TABLE "orders" ( + "id" int PRIMARY KEY AUTOINCREMENT, + "user_id" int UNIQUE NOT NULL, + "status" "orders_status", + "created_at" varchar +); +... + +``` + +Generate DBML for your Database by accessing the `dbml` property: + +```python +>>> parsed.project.items['author'] = 'John Doe' +>>> print(parsed.dbml) # doctest:+ELLIPSIS +Project "test_schema" { + author: 'John Doe' + Note { + 'This schema is used for PyDBML doctest' + } +} +<BLANKLINE> +Enum "orders_status" { + "created" + "running" + "done" + "failure" +} +<BLANKLINE> +Enum "product status" { + "Out of Stock" + "In Stock" +} +<BLANKLINE> +Table "orders" { + "id" int [pk, increment] + "user_id" int [unique, not null] + "status" "orders_status" + "created_at" varchar +} +<BLANKLINE> +Table "order_items" { + "order_id" int + "product_id" int + "quantity" int [default: 1] +} +... + +``` + + +%package -n python3-pydbml +Summary: Python parser and builder for DBML +Provides: python-pydbml +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pydbml +[](https://pypi.org/project/pydbml/) [](https://pypi.org/project/pydbml/) [](https://github.com/Vanderhoof/PyDBML)  + +# DBML parser for Python + +*Compliant with DBML **v2.4.4** syntax* + +PyDBML is a Python parser and builder for [DBML](https://www.dbml.org) syntax. + +> The project was rewritten in May 2022, the new version 1.0.0 is not compatible with the previous ones. See details in [Upgrading to PyDBML 1.0.0](docs/upgrading.md). + +**Docs:** + +* [Class Reference](docs/classes.md) +* [Creating DBML schema](docs/creating_schema.md) +* [Upgrading to PyDBML 1.0.0](docs/upgrading.md) + +> PyDBML requires Python v3.8 or higher + +## Installation + +You can install PyDBML using pip: + +```bash +pip3 install pydbml +``` + +## Quick start + +To parse a DBML file, import the `PyDBML` class and initialize it with Path object + +```python +>>> from pydbml import PyDBML +>>> from pathlib import Path +>>> parsed = PyDBML(Path('test_schema.dbml')) + +``` + +or with file stream + +```python +>>> with open('test_schema.dbml') as f: +... parsed = PyDBML(f) + +``` + +or with entire source string + +```python +>>> with open('test_schema.dbml') as f: +... source = f.read() +>>> parsed = PyDBML(source) +>>> parsed +<Database> + +``` + +The parser returns a Database object that is a container for the parsed DBML entities. + +You can access tables inside the `tables` attribute: + +```python +>>> for table in parsed.tables: +... print(table.name) +... +orders +order_items +products +users +merchants +countries + +``` + +Or just by getting items by index or full table name: + +```python +>>> parsed[1] +<Table 'public' 'order_items'> +>>> parsed['public.countries'] +<Table 'public' 'countries'> + +``` + +Other attributes are: + +* **refs** — list of all references, +* **enums** — list of all enums, +* **table_groups** — list of all table groups, +* **project** — the Project object, if was defined. + +Generate SQL for your DBML Database by accessing the `sql` property: + +```python +>>> print(parsed.sql) # doctest:+ELLIPSIS +CREATE TYPE "orders_status" AS ENUM ( + 'created', + 'running', + 'done', + 'failure', +); +<BLANKLINE> +CREATE TYPE "product status" AS ENUM ( + 'Out of Stock', + 'In Stock', +); +<BLANKLINE> +CREATE TABLE "orders" ( + "id" int PRIMARY KEY AUTOINCREMENT, + "user_id" int UNIQUE NOT NULL, + "status" "orders_status", + "created_at" varchar +); +... + +``` + +Generate DBML for your Database by accessing the `dbml` property: + +```python +>>> parsed.project.items['author'] = 'John Doe' +>>> print(parsed.dbml) # doctest:+ELLIPSIS +Project "test_schema" { + author: 'John Doe' + Note { + 'This schema is used for PyDBML doctest' + } +} +<BLANKLINE> +Enum "orders_status" { + "created" + "running" + "done" + "failure" +} +<BLANKLINE> +Enum "product status" { + "Out of Stock" + "In Stock" +} +<BLANKLINE> +Table "orders" { + "id" int [pk, increment] + "user_id" int [unique, not null] + "status" "orders_status" + "created_at" varchar +} +<BLANKLINE> +Table "order_items" { + "order_id" int + "product_id" int + "quantity" int [default: 1] +} +... + +``` + + +%package help +Summary: Development documents and examples for pydbml +Provides: python3-pydbml-doc +%description help +[](https://pypi.org/project/pydbml/) [](https://pypi.org/project/pydbml/) [](https://github.com/Vanderhoof/PyDBML)  + +# DBML parser for Python + +*Compliant with DBML **v2.4.4** syntax* + +PyDBML is a Python parser and builder for [DBML](https://www.dbml.org) syntax. + +> The project was rewritten in May 2022, the new version 1.0.0 is not compatible with the previous ones. See details in [Upgrading to PyDBML 1.0.0](docs/upgrading.md). + +**Docs:** + +* [Class Reference](docs/classes.md) +* [Creating DBML schema](docs/creating_schema.md) +* [Upgrading to PyDBML 1.0.0](docs/upgrading.md) + +> PyDBML requires Python v3.8 or higher + +## Installation + +You can install PyDBML using pip: + +```bash +pip3 install pydbml +``` + +## Quick start + +To parse a DBML file, import the `PyDBML` class and initialize it with Path object + +```python +>>> from pydbml import PyDBML +>>> from pathlib import Path +>>> parsed = PyDBML(Path('test_schema.dbml')) + +``` + +or with file stream + +```python +>>> with open('test_schema.dbml') as f: +... parsed = PyDBML(f) + +``` + +or with entire source string + +```python +>>> with open('test_schema.dbml') as f: +... source = f.read() +>>> parsed = PyDBML(source) +>>> parsed +<Database> + +``` + +The parser returns a Database object that is a container for the parsed DBML entities. + +You can access tables inside the `tables` attribute: + +```python +>>> for table in parsed.tables: +... print(table.name) +... +orders +order_items +products +users +merchants +countries + +``` + +Or just by getting items by index or full table name: + +```python +>>> parsed[1] +<Table 'public' 'order_items'> +>>> parsed['public.countries'] +<Table 'public' 'countries'> + +``` + +Other attributes are: + +* **refs** — list of all references, +* **enums** — list of all enums, +* **table_groups** — list of all table groups, +* **project** — the Project object, if was defined. + +Generate SQL for your DBML Database by accessing the `sql` property: + +```python +>>> print(parsed.sql) # doctest:+ELLIPSIS +CREATE TYPE "orders_status" AS ENUM ( + 'created', + 'running', + 'done', + 'failure', +); +<BLANKLINE> +CREATE TYPE "product status" AS ENUM ( + 'Out of Stock', + 'In Stock', +); +<BLANKLINE> +CREATE TABLE "orders" ( + "id" int PRIMARY KEY AUTOINCREMENT, + "user_id" int UNIQUE NOT NULL, + "status" "orders_status", + "created_at" varchar +); +... + +``` + +Generate DBML for your Database by accessing the `dbml` property: + +```python +>>> parsed.project.items['author'] = 'John Doe' +>>> print(parsed.dbml) # doctest:+ELLIPSIS +Project "test_schema" { + author: 'John Doe' + Note { + 'This schema is used for PyDBML doctest' + } +} +<BLANKLINE> +Enum "orders_status" { + "created" + "running" + "done" + "failure" +} +<BLANKLINE> +Enum "product status" { + "Out of Stock" + "In Stock" +} +<BLANKLINE> +Table "orders" { + "id" int [pk, increment] + "user_id" int [unique, not null] + "status" "orders_status" + "created_at" varchar +} +<BLANKLINE> +Table "order_items" { + "order_id" int + "product_id" int + "quantity" int [default: 1] +} +... + +``` + + +%prep +%autosetup -n pydbml-1.0.7 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-pydbml -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.7-1 +- Package Spec generated |