From d12fc72c9ff1bb7b0d13ec198d9a7c8d97f35754 Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Wed, 12 Apr 2023 02:14:49 +0000 Subject: automatic import of python-pydantic-sqlalchemy --- .gitignore | 1 + python-pydantic-sqlalchemy.spec | 527 ++++++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 529 insertions(+) create mode 100644 python-pydantic-sqlalchemy.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..599ad6a 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/pydantic-sqlalchemy-0.0.9.tar.gz diff --git a/python-pydantic-sqlalchemy.spec b/python-pydantic-sqlalchemy.spec new file mode 100644 index 0000000..fb327be --- /dev/null +++ b/python-pydantic-sqlalchemy.spec @@ -0,0 +1,527 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pydantic-sqlalchemy +Version: 0.0.9 +Release: 1 +Summary: Tools to convert SQLAlchemy models to Pydantic models +License: MIT +URL: https://pypi.org/project/pydantic-sqlalchemy/ +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a4/92/a763ab9e19a4f1dc494d3d0577c4074e295c33a89aebd1aa7b0bf20bfb88/pydantic-sqlalchemy-0.0.9.tar.gz +BuildArch: noarch + +Requires: python3-sqlalchemy +Requires: python3-pydantic +Requires: python3-jupyter[dev] +Requires: python3-autoflake[dev] +Requires: python3-flake8[dev] + +%description +# Pydantic-SQLAlchemy + + + Test + + + Publish + + + Coverage + + + Package version + + +Tools to generate Pydantic models from SQLAlchemy models. + +Still experimental. + +## How to use + +Quick example: + +```Python +from typing import List + +from pydantic_sqlalchemy import sqlalchemy_to_pydantic +from sqlalchemy import Column, ForeignKey, Integer, String, create_engine +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import Session, relationship, sessionmaker + +Base = declarative_base() + +engine = create_engine("sqlite://", echo=True) + + +class User(Base): + __tablename__ = "users" + + id = Column(Integer, primary_key=True) + name = Column(String) + fullname = Column(String) + nickname = Column(String) + + addresses = relationship( + "Address", back_populates="user", cascade="all, delete, delete-orphan" + ) + + +class Address(Base): + __tablename__ = "addresses" + id = Column(Integer, primary_key=True) + email_address = Column(String, nullable=False) + user_id = Column(Integer, ForeignKey("users.id")) + + user = relationship("User", back_populates="addresses") + + +PydanticUser = sqlalchemy_to_pydantic(User) +PydanticAddress = sqlalchemy_to_pydantic(Address) + + +class PydanticUserWithAddresses(PydanticUser): + addresses: List[PydanticAddress] = [] + + +Base.metadata.create_all(engine) + + +LocalSession = sessionmaker(bind=engine) + +db: Session = LocalSession() + +ed_user = User(name="ed", fullname="Ed Jones", nickname="edsnickname") + +address = Address(email_address="ed@example.com") +address2 = Address(email_address="eddy@example.com") +ed_user.addresses = [address, address2] +db.add(ed_user) +db.commit() + + +def test_pydantic_sqlalchemy(): + user = db.query(User).first() + pydantic_user = PydanticUser.from_orm(user) + data = pydantic_user.dict() + assert data == { + "fullname": "Ed Jones", + "id": 1, + "name": "ed", + "nickname": "edsnickname", + } + pydantic_user_with_addresses = PydanticUserWithAddresses.from_orm(user) + data = pydantic_user_with_addresses.dict() + assert data == { + "fullname": "Ed Jones", + "id": 1, + "name": "ed", + "nickname": "edsnickname", + "addresses": [ + {"email_address": "ed@example.com", "id": 1, "user_id": 1}, + {"email_address": "eddy@example.com", "id": 2, "user_id": 1}, + ], + } +``` + +## Release Notes + +### Latest Changes + + +### 0.0.9 + +* ✨ Add `poetry-version-plugin`, remove `importlib-metadata` dependency. PR [#32](https://github.com/tiangolo/pydantic-sqlalchemy/pull/32) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.8.post1 + +* 💚 Fix setting up Poetry for GitHub Action Publish. PR [#23](https://github.com/tiangolo/pydantic-sqlalchemy/pull/23) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.8 + +* ⬆️ Upgrade `importlib-metadata` to 3.0.0. PR [#22](https://github.com/tiangolo/pydantic-sqlalchemy/pull/22) by [@tiangolo](https://github.com/tiangolo). +* 👷 Add GitHub Action latest-changes. PR [#20](https://github.com/tiangolo/pydantic-sqlalchemy/pull/20) by [@tiangolo](https://github.com/tiangolo). +* 💚 Fix GitHub Actions Poetry setup. PR [#21](https://github.com/tiangolo/pydantic-sqlalchemy/pull/21) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.7 + +* Update requirements of `importlib-metadata` to support the latest version `2.0.0`. PR [#11](https://github.com/tiangolo/pydantic-sqlalchemy/pull/11). + +### 0.0.6 + +* Add support for SQLAlchemy extended types like [sqlalchemy-utc: UtcDateTime](https://github.com/spoqa/sqlalchemy-utc). PR [#9](https://github.com/tiangolo/pydantic-sqlalchemy/pull/9). + +### 0.0.5 + +* Exclude columns before checking their Python types. PR [#5](https://github.com/tiangolo/pydantic-sqlalchemy/pull/5) by [@ZachMyers3](https://github.com/ZachMyers3). + +### 0.0.4 + +* Do not include SQLAlchemy defaults in Pydantic models. PR [#4](https://github.com/tiangolo/pydantic-sqlalchemy/pull/4). + +### 0.0.3 + +* Add support for `exclude` to exclude columns from Pydantic model. PR [#3](https://github.com/tiangolo/pydantic-sqlalchemy/pull/3). +* Add support for overriding the Pydantic `config`. PR [#1](https://github.com/tiangolo/pydantic-sqlalchemy/pull/1) by [@pyropy](https://github.com/pyropy). +* Add CI with GitHub Actions. PR [#2](https://github.com/tiangolo/pydantic-sqlalchemy/pull/2). + +## License + +This project is licensed under the terms of the MIT license. + + +%package -n python3-pydantic-sqlalchemy +Summary: Tools to convert SQLAlchemy models to Pydantic models +Provides: python-pydantic-sqlalchemy +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pydantic-sqlalchemy +# Pydantic-SQLAlchemy + + + Test + + + Publish + + + Coverage + + + Package version + + +Tools to generate Pydantic models from SQLAlchemy models. + +Still experimental. + +## How to use + +Quick example: + +```Python +from typing import List + +from pydantic_sqlalchemy import sqlalchemy_to_pydantic +from sqlalchemy import Column, ForeignKey, Integer, String, create_engine +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import Session, relationship, sessionmaker + +Base = declarative_base() + +engine = create_engine("sqlite://", echo=True) + + +class User(Base): + __tablename__ = "users" + + id = Column(Integer, primary_key=True) + name = Column(String) + fullname = Column(String) + nickname = Column(String) + + addresses = relationship( + "Address", back_populates="user", cascade="all, delete, delete-orphan" + ) + + +class Address(Base): + __tablename__ = "addresses" + id = Column(Integer, primary_key=True) + email_address = Column(String, nullable=False) + user_id = Column(Integer, ForeignKey("users.id")) + + user = relationship("User", back_populates="addresses") + + +PydanticUser = sqlalchemy_to_pydantic(User) +PydanticAddress = sqlalchemy_to_pydantic(Address) + + +class PydanticUserWithAddresses(PydanticUser): + addresses: List[PydanticAddress] = [] + + +Base.metadata.create_all(engine) + + +LocalSession = sessionmaker(bind=engine) + +db: Session = LocalSession() + +ed_user = User(name="ed", fullname="Ed Jones", nickname="edsnickname") + +address = Address(email_address="ed@example.com") +address2 = Address(email_address="eddy@example.com") +ed_user.addresses = [address, address2] +db.add(ed_user) +db.commit() + + +def test_pydantic_sqlalchemy(): + user = db.query(User).first() + pydantic_user = PydanticUser.from_orm(user) + data = pydantic_user.dict() + assert data == { + "fullname": "Ed Jones", + "id": 1, + "name": "ed", + "nickname": "edsnickname", + } + pydantic_user_with_addresses = PydanticUserWithAddresses.from_orm(user) + data = pydantic_user_with_addresses.dict() + assert data == { + "fullname": "Ed Jones", + "id": 1, + "name": "ed", + "nickname": "edsnickname", + "addresses": [ + {"email_address": "ed@example.com", "id": 1, "user_id": 1}, + {"email_address": "eddy@example.com", "id": 2, "user_id": 1}, + ], + } +``` + +## Release Notes + +### Latest Changes + + +### 0.0.9 + +* ✨ Add `poetry-version-plugin`, remove `importlib-metadata` dependency. PR [#32](https://github.com/tiangolo/pydantic-sqlalchemy/pull/32) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.8.post1 + +* 💚 Fix setting up Poetry for GitHub Action Publish. PR [#23](https://github.com/tiangolo/pydantic-sqlalchemy/pull/23) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.8 + +* ⬆️ Upgrade `importlib-metadata` to 3.0.0. PR [#22](https://github.com/tiangolo/pydantic-sqlalchemy/pull/22) by [@tiangolo](https://github.com/tiangolo). +* 👷 Add GitHub Action latest-changes. PR [#20](https://github.com/tiangolo/pydantic-sqlalchemy/pull/20) by [@tiangolo](https://github.com/tiangolo). +* 💚 Fix GitHub Actions Poetry setup. PR [#21](https://github.com/tiangolo/pydantic-sqlalchemy/pull/21) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.7 + +* Update requirements of `importlib-metadata` to support the latest version `2.0.0`. PR [#11](https://github.com/tiangolo/pydantic-sqlalchemy/pull/11). + +### 0.0.6 + +* Add support for SQLAlchemy extended types like [sqlalchemy-utc: UtcDateTime](https://github.com/spoqa/sqlalchemy-utc). PR [#9](https://github.com/tiangolo/pydantic-sqlalchemy/pull/9). + +### 0.0.5 + +* Exclude columns before checking their Python types. PR [#5](https://github.com/tiangolo/pydantic-sqlalchemy/pull/5) by [@ZachMyers3](https://github.com/ZachMyers3). + +### 0.0.4 + +* Do not include SQLAlchemy defaults in Pydantic models. PR [#4](https://github.com/tiangolo/pydantic-sqlalchemy/pull/4). + +### 0.0.3 + +* Add support for `exclude` to exclude columns from Pydantic model. PR [#3](https://github.com/tiangolo/pydantic-sqlalchemy/pull/3). +* Add support for overriding the Pydantic `config`. PR [#1](https://github.com/tiangolo/pydantic-sqlalchemy/pull/1) by [@pyropy](https://github.com/pyropy). +* Add CI with GitHub Actions. PR [#2](https://github.com/tiangolo/pydantic-sqlalchemy/pull/2). + +## License + +This project is licensed under the terms of the MIT license. + + +%package help +Summary: Development documents and examples for pydantic-sqlalchemy +Provides: python3-pydantic-sqlalchemy-doc +%description help +# Pydantic-SQLAlchemy + + + Test + + + Publish + + + Coverage + + + Package version + + +Tools to generate Pydantic models from SQLAlchemy models. + +Still experimental. + +## How to use + +Quick example: + +```Python +from typing import List + +from pydantic_sqlalchemy import sqlalchemy_to_pydantic +from sqlalchemy import Column, ForeignKey, Integer, String, create_engine +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import Session, relationship, sessionmaker + +Base = declarative_base() + +engine = create_engine("sqlite://", echo=True) + + +class User(Base): + __tablename__ = "users" + + id = Column(Integer, primary_key=True) + name = Column(String) + fullname = Column(String) + nickname = Column(String) + + addresses = relationship( + "Address", back_populates="user", cascade="all, delete, delete-orphan" + ) + + +class Address(Base): + __tablename__ = "addresses" + id = Column(Integer, primary_key=True) + email_address = Column(String, nullable=False) + user_id = Column(Integer, ForeignKey("users.id")) + + user = relationship("User", back_populates="addresses") + + +PydanticUser = sqlalchemy_to_pydantic(User) +PydanticAddress = sqlalchemy_to_pydantic(Address) + + +class PydanticUserWithAddresses(PydanticUser): + addresses: List[PydanticAddress] = [] + + +Base.metadata.create_all(engine) + + +LocalSession = sessionmaker(bind=engine) + +db: Session = LocalSession() + +ed_user = User(name="ed", fullname="Ed Jones", nickname="edsnickname") + +address = Address(email_address="ed@example.com") +address2 = Address(email_address="eddy@example.com") +ed_user.addresses = [address, address2] +db.add(ed_user) +db.commit() + + +def test_pydantic_sqlalchemy(): + user = db.query(User).first() + pydantic_user = PydanticUser.from_orm(user) + data = pydantic_user.dict() + assert data == { + "fullname": "Ed Jones", + "id": 1, + "name": "ed", + "nickname": "edsnickname", + } + pydantic_user_with_addresses = PydanticUserWithAddresses.from_orm(user) + data = pydantic_user_with_addresses.dict() + assert data == { + "fullname": "Ed Jones", + "id": 1, + "name": "ed", + "nickname": "edsnickname", + "addresses": [ + {"email_address": "ed@example.com", "id": 1, "user_id": 1}, + {"email_address": "eddy@example.com", "id": 2, "user_id": 1}, + ], + } +``` + +## Release Notes + +### Latest Changes + + +### 0.0.9 + +* ✨ Add `poetry-version-plugin`, remove `importlib-metadata` dependency. PR [#32](https://github.com/tiangolo/pydantic-sqlalchemy/pull/32) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.8.post1 + +* 💚 Fix setting up Poetry for GitHub Action Publish. PR [#23](https://github.com/tiangolo/pydantic-sqlalchemy/pull/23) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.8 + +* ⬆️ Upgrade `importlib-metadata` to 3.0.0. PR [#22](https://github.com/tiangolo/pydantic-sqlalchemy/pull/22) by [@tiangolo](https://github.com/tiangolo). +* 👷 Add GitHub Action latest-changes. PR [#20](https://github.com/tiangolo/pydantic-sqlalchemy/pull/20) by [@tiangolo](https://github.com/tiangolo). +* 💚 Fix GitHub Actions Poetry setup. PR [#21](https://github.com/tiangolo/pydantic-sqlalchemy/pull/21) by [@tiangolo](https://github.com/tiangolo). + +### 0.0.7 + +* Update requirements of `importlib-metadata` to support the latest version `2.0.0`. PR [#11](https://github.com/tiangolo/pydantic-sqlalchemy/pull/11). + +### 0.0.6 + +* Add support for SQLAlchemy extended types like [sqlalchemy-utc: UtcDateTime](https://github.com/spoqa/sqlalchemy-utc). PR [#9](https://github.com/tiangolo/pydantic-sqlalchemy/pull/9). + +### 0.0.5 + +* Exclude columns before checking their Python types. PR [#5](https://github.com/tiangolo/pydantic-sqlalchemy/pull/5) by [@ZachMyers3](https://github.com/ZachMyers3). + +### 0.0.4 + +* Do not include SQLAlchemy defaults in Pydantic models. PR [#4](https://github.com/tiangolo/pydantic-sqlalchemy/pull/4). + +### 0.0.3 + +* Add support for `exclude` to exclude columns from Pydantic model. PR [#3](https://github.com/tiangolo/pydantic-sqlalchemy/pull/3). +* Add support for overriding the Pydantic `config`. PR [#1](https://github.com/tiangolo/pydantic-sqlalchemy/pull/1) by [@pyropy](https://github.com/pyropy). +* Add CI with GitHub Actions. PR [#2](https://github.com/tiangolo/pydantic-sqlalchemy/pull/2). + +## License + +This project is licensed under the terms of the MIT license. + + +%prep +%autosetup -n pydantic-sqlalchemy-0.0.9 + +%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-pydantic-sqlalchemy -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed Apr 12 2023 Python_Bot - 0.0.9-1 +- Package Spec generated diff --git a/sources b/sources new file mode 100644 index 0000000..72b6773 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +d4748f92a38b7514728c77a82d0b1c0d pydantic-sqlalchemy-0.0.9.tar.gz -- cgit v1.2.3