Comments (1)
I got it working.
Here is my approach:
from sqlalchemy import (
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
String,
Text
)
import sqlalchemy.dialects.postgresql as postgresql
import uuid
from sqlalchemy.sql import func
Base = declarative_base()
class Column(Base):
_id = Column(postgresql.UUID(as_uuid=True),
primary_key=True,
default=uuid.uuid4,
unique=True
)
_created = Column(DateTime,
default=func.now())
_updated = Column(DateTime,
default=func.now(),
onupdate=func.now())
_etag = Column(Text)
I had to set type
of _id
for each column to be "uuid
- DOMAIN["tasks"]["schema"]["_id"]["type"] = "uuid"
Implemented UUIDValidator
and UUIDEncoder
from here - https://docs.python-eve.org/en/latest/tutorials/custom_idfields.html#custom-jsonencoder
and passed it to Eve app:
app = Eve(validator= UUIDValidator,
json_encoder= UUIDEncoder,
data=SQL)
One key aspect is that you have to generate _id
yourself - uuid.uuid4().hex
- and pass it as part of POST. It is not needed when you add straight to db.
Hope it helps someone :)
from eve-sqlalchemy.
Related Issues (20)
- Creating model instance does not respect "viewonly" relationship attribute HOT 1
- 502 for PATCH HOT 1
- Cannot replace BaseQuery with a Custom query_class (soft delete custom query class) HOT 1
- How to add validations with Eve-sqlalchemy HOT 1
- Is OPLOG supported? HOT 5
- any plan to keep updated with eve ? HOT 1
- Updating datasource leads to KeyError HOT 2
- Missing documentation on how to install
- TypeError: find() got an unexpected keyword argument 'perform_count' HOT 1
- eve.exceptions.ConfigException: User.id is not unique HOT 1
- Please specify `related_resources` manually HOT 2
- TypeError: '_updated' is an invalid keyword argument for Network HOT 2
- Is it possible to change compatible version of Eve from "<0.8" to the latest Eve? HOT 1
- Many-to-many issue HOT 1
- UserWarning: No validation schema is defined for the arguments of rule 'data_relation' / 'dependencies' / 'unique' HOT 1
- when will be eve_sqlalchemy update? HOT 2
- Support for SQLAlchemy 1.4
- Upgrade to eve-sqlalchemy 0.7.1 / hybrid_property / AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with <relation> has an attribute <column>
- ImportError: cannot import name 'Iterable' from 'collections'
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 eve-sqlalchemy.