Skip to main content

SQLAlchemy Model Builder

Project description

SQLAlchemy Model Builder

test publish codecov pypi

Features

  • Build SQLAlchemy model instance with random data
  • Save SQLAlchemy model instance with random data
  • Build relationships
  • Build minimal (with required fields) only

Installation

$ pip install sqladmin

How to use

Deinfe the SQLAlchemy models:

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql.sqltypes import Integer, String, Text

Base = declarative_base()


class Address(Base):
    __tablename__ = "addresses"

    id = Column(Integer, primary_key=True)
    user_id = Column(Integer, ForeignKey("users.id"))
    user = relationship("User", back_populates="addresses")


class User(Base):
    __tablename__ = "users"

    addresses = relationship("Address", back_populates="user")
    bio = Column(Text)
    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=False)

Save random model instance:

from sqlalchemy_model_builder import ModelBuilder

random_user = ModelBuilder(User).save(db)

Build random model without saving:

random_user = ModelBuilder(User).build()

Build minimal model instance:

minimal_random_user = ModelBuilder(User, minimal=True).build()

Build or save with specific values:

random_address = ModelBuilder(Address).build(user_id=1)

Supported Data Types

  • BigInteger
  • Boolean
  • Date
  • DateTime
  • Enum
  • Float
  • Integer
  • Interval
  • LargeBinary
  • MatchType (Todo)
  • Numeric
  • PickleType (Todo)
  • SchemaType (Todo)
  • SmallInteger
  • String
  • Text
  • Time
  • Unicode
  • UnicodeText

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

sqlalchemy_model_builder-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

sqlalchemy_model_builder-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for sqlalchemy_model_builder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 30f280f8d4de8551386cbf0606817a5edab47076db3f1ac633e82a71c16277d2
MD5 db3a7ec5eb0560d78634c407b13bb60b
BLAKE2b-256 cd7e88391bb7634827f2f60ad98d60d08aad3fcf7b61b6adaf5591aaa3d05343

See more details on using hashes here.

File details

Details for the file sqlalchemy_model_builder-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemy_model_builder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 641c435741391061941b4084117fb8248efb1e35ed467ba5ef0f5c575691f29a
MD5 9924a6840a77c97afd98988e2596aef4
BLAKE2b-256 ca67539ce54f1dcae5de50cd8651c94afe3763274fa4a70e6c3311fec81f038a

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