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.2.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

sqlalchemy_model_builder-0.2.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for sqlalchemy_model_builder-0.2.0.tar.gz
Algorithm Hash digest
SHA256 54c1cc1d92ce67448d7daaafb51df9052edf1c5ef7b038f6afabb24ddd7b7c7c
MD5 582760972625c4f794c30ee753a13c7d
BLAKE2b-256 8668002abb41fae7ecf0ca3843721bd9e3af6f3bfab508af2eda3b25a3585485

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sqlalchemy_model_builder-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3beb5da69c3f994dcea6765e36ef30bcebbbdc83873ef3d888d5adf747f4c46e
MD5 9946af1882661aedf45827d569953540
BLAKE2b-256 116cee3f93e3cebe0466e2a96781c5d86020932d2aae0bda6e2dfcfc83e2a104

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