SQLAlchemy Model Builder
Project description
SQLAlchemy Model Builder
Features
- Build and Save SQLALchemy models with random data
- Build relationships (Todo)
- Build with minimal (required) fields only (Todo)
How to use
Build SQLAlchemy model:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql.sqltypes import Integer, String
from sqlalchemy_model_builder import ModelBuilder
Base = declarative_base()
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
name = Column(String)
random_user = ModelBuilder(User).build() # Note: This will not insert the User
Save SQLAlchemy model:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql.sqltypes import Integer, String
from sqlalchemy_model_builder import ModelBuilder
Base = declarative_base()
engine = create_engine("sqlite://", echo=True)
class User(Base):
__tablename__ = "users"
bio = Column(Text)
id = Column(Integer, primary_key=True)
name = Column(String)
Base.metadata.create_all(engine)
LocalSession = sessionmaker(bind=engine)
db = LocalSession()
random_user = ModelBuilder(User).save(db=db) # Note: Builds and Saves model using provided session
Supported Data Types
- BigInteger
- Boolean
- Date
- DateTime
- Enum (Todo)
- Float
- Integer
- Interval
- LargeBinary (Todo)
- MatchType (Todo)
- Numeric (Todo)
- 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
Built Distribution
File details
Details for the file sqlalchemy-model-builder-0.0.2.tar.gz
.
File metadata
- Download URL: sqlalchemy-model-builder-0.0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0a1 CPython/3.8.10 Linux/5.4.0-1047-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b81fe4df4447777ff53cb0d559d30d036f9f0f3889d4bbe6eef50971beb1fcc9 |
|
MD5 | e5a3c664f2e60e55f25269fd47ca2e7b |
|
BLAKE2b-256 | e72d14cacd3306398f5f3b8603183b20ccbed4c0d7b967b051596c88ff129c94 |
File details
Details for the file sqlalchemy_model_builder-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: sqlalchemy_model_builder-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0a1 CPython/3.8.10 Linux/5.4.0-1047-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72f256efa63ffcb8c5cb070eb4d9b68a4775f7cc4b96fed63b6f714161c9f1c7 |
|
MD5 | 6ed4cbd2f900557d95c4cb88a8aa7699 |
|
BLAKE2b-256 | 1922ff2305ad86942b9680f666daee52f64931117523a41a1beac78d0fa2a165 |