Skip to main content

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 sqlalchemy-model-builder

How to use

Deinfe the SQLAlchemy models:

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

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

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for sqlalchemy_model_builder-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4230c18cb1c723197b363cd8af1f127a4d4e971021288653f1fd726718e9f2da
MD5 d7d225a9ecbb371f3f4d632f8bcee480
BLAKE2b-256 3134cbd275403ce60394e835eac0490b252f6c0e8b33bd35480c78e19c3a9815

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sqlalchemy_model_builder-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b578086b97211340e18686a806cff71ab04f99c00d17db2830b248557f3170f2
MD5 0d7fa50155bd6874e9d379c538272002
BLAKE2b-256 82e5bb2f0bcff60645f67f75f24a1455ed4e24c588e42288f47f3119df09cf14

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.0

2 files

0.0.6

2 files

0.0.5

2 files

0.0.3

2 files

0.0.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page