Comments (9)
I think the scope of this project is exactly what you described it: a grab-bag of utils for sqlalchemy. As for larger extensions we could create entirely new repositories. I've already done this with:
https://github.com/kvesteri/wtforms-alchemy
https://github.com/kvesteri/sqlalchemy-continuum
https://github.com/kvesteri/sqlalchemy-i18n
https://github.com/kvesteri/sqlalchemy-defaults
As for the features you suggested, here is my two cents:
- auto created / updated time columns - please give desired API for this
- uuid column - good idea, maybe this could be implemented as a uuid typedecorator which would use underlying native database uuid type whenever possible (atleast in the case of pgsql)
- timezone column - very good idea, maybe a timezone typedecorator instead of column?
- data-based fixtures - I already created a package for sqlalchemy fixtures: https://github.com/kvesteri/sqlalchemy-fixtures. This package sucks though. Our company switched to using this: https://github.com/dnerdy/factory_boy (we added sqlalchemy driver for it, I think we haven't yet made a pull request there though)
- django style object manager - good idea once again, maybe we should first start with the desired API for this?
- declarative permissions using binary expressions - once again good idea, I'd love to see the API for this
from sqlalchemy-utils.
I added you as a contributor for this project.
from sqlalchemy-utils.
I added you as a contributor for this project.
Good stuff; I appreciate it. I'm going to start by opening issues for a few of these.
from sqlalchemy-utils.
Thanks for creating the issues, great stuff! Out of curiosity which MVC framework are you using?
from sqlalchemy-utils.
As our development focuses primarily on RESTful interfaces, we use https://github.com/armet/python-armet as the view / controller layer.
Armet is a framework-agnostic REST framework. Currently it connects to django, bottle, cyclone, and flask for the http layer and django or sqlalchemy for the model layer (and any combination of the two layers is supported).
We're using it tied to flask for the http layer at the moment with (semi-obviously) sqlalchemy for the model layer.
from sqlalchemy-utils.
@kvesteri Let me know what you think of alchemist: https://github.com/concordusapps/alchemist
It's meant to be the glue between flask and sqlalchemy using many of the same conventions django provides (such as segmented applications). It also provides (using flask-script) a powerful CLI to manage the db, server, etc.
from sqlalchemy-utils.
I like many of the concepts you have there. Maybe this package would be better split in two separate concerns? How about Flask-Packages and Flask-AlchemyScript (or Flask-Script-SQLAlchemy :) ?.
from sqlalchemy-utils.
@mehcode What kind of data validation are you using for REST APIs? We've used WTForms along with WTForms-JSON and WTForms-Alchemy for data validation with POST, PUT and PATCH requests. It would be great if we could collaborate on these projects too.
from sqlalchemy-utils.
https://github.com/armet/python-armet has its own internal validation:
from armet import resources
from . import models
class Resource(resources.ModelResource):
class Meta:
connectors = {'http': 'flask', 'model': 'sqlalchemy'}
model = models.User
def clean_name(self, value):
assert len(value) > 10, 'Name must be longer than 10 characters'
return value
With the above definition and the following request...
POST /user
{"name": "bob"}
The response would be ...
400
{ "name": ['Name must be longer than 10 characters']}
The idea is any ValueErrors or AssertionErrors that get triggered anywhere get collected according to the context of the call and formed into this error dictionary. For instance, this allows any assert
s in the sqlalchemy model validators to become nice 400-code responses for the client.
Futerhmore, I've been planning to allow linking up a django form to handle validation (in django of course).
class Resource(resources.ModelResource):
class Meta:
connectors = {'http': 'flask', 'model': 'django'}
form = UserForm
It'd be nice to have other form libraries to plugin into armet (like WTForms). I'll definitely put it on the TODO list to create the binding between WTForms
and armet. It looks nice. I'll take a look in there to see if there's anything extra I need, etc. when I get to this.
Along the same line of thinking, I'd love to get some collaboration going for armet if you're interested. Most of my free time next week I have set aside for documentation, website, and various things for it.
from sqlalchemy-utils.
Related Issues (20)
- Unable to call refresh_materialized_view on CRDB w/SQLAlchemy 2.0 HOT 1
- Create SECURITY.md
- CompositeType support for pg8000 and psycopg3 HOT 1
- create_view not accepting `replace` argument HOT 2
- Helper functions for explicit table locks ?
- custom aggregated column does not work with nullable=False
- Database_exist not working in python 3.11 HOT 1
- Even though binary was set false, impl remain binary(16)
- generic_relationship breaks with SqlAlchemy 2.0.22 HOT 3
- [Feature] Add MySQL collation support in `create_database`
- DeprecationWarning: 'crypt' is deprecated HOT 1
- Issue with change of implementation of EncryptedType from ‘LargeBinary’ to ‘String’ HOT 1
- [Feature] Enable Cascade Behavior for generic_relationship
- [Question] how to encrypt using aws kms in sqlalchemy
- Error on model with `server_default` for `DateTime` column and `UUIDType` primary key.
- [Feature] database helpers functions don't support custom create_engine()
- New release for SQLAlchemy >= 2.0.22 HOT 19
- Issue updating aggregate when setting foreign key to Null HOT 1
- Password checking error when using SQLAlchemy and Postgres
- [Feature] `auto_delete_orphans` not support `back_populates` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlalchemy-utils.