kvesteri / sqlalchemy-defaults Goto Github PK
View Code? Open in Web Editor NEWSmart SQLAlchemy defaults for lazy guys, like me.
License: Other
Smart SQLAlchemy defaults for lazy guys, like me.
License: Other
Psycopg requires you to have PostgreSQL installed, which is kinda silly if you're not actually using postgres as the database backend. Is this only intended for postgres?
The method append_check_constraints
(https://github.com/kvesteri/sqlalchemy-defaults/blob/d92dd9a2dfb0291fc643adb1ea76b7b41233d4f7/sqlalchemy_defaults/__init__.py#L74-87) expects that the min
and max
column info attributes are integers. At least for Date
and DateTime
columns this is not the case. See example from WTForms-Alchemy's documentation regarding DateTime
column and min
attribute: http://wtforms-alchemy.readthedocs.org/en/latest/validators.html#range-validators.
Taking the code from your example:
import sqlalchemy as sa
from sqlalchemy_defaults import Column
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = 'user'
__lazy_options__ = {}
id = Column(sa.Integer, primary_key=True)
name = Column(
sa.Unicode(255),
)
description = Column(
sa.Unicode(255),
default=u'',
)
is_admin = Column(
sa.Boolean,
)
created_at = Column(
sa.DateTime,
auto_now=True
)
hobbies = Column(
sa.Integer,
min=1,
max=4
)
from sqlalchemy_defaults import make_lazy_configured
make_lazy_configured(sa.orm.mapper)
print('User.description.default:', User.description.default)
print('User.description.server_default:', User.description.server_default)
Running this code gives me:
User.description.default: ColumnDefault('')
User.description.server_default: None
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.