Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
If you are working with #Cement, #Flask or other python frameworks that do not give ODM (Object Document Mapper) out of the box, you can use MongoEngine for MongoDB.
It has all the capabilities that you can almost imagine for an ODM to define schema and apply restrictions to it. You'll hear more about it later.

https://github.com/MongoEngine/mongoengine

#mongodb #mongoengine #ODM #python #ORM
How to find the query associated with a queryset in Django ORM?

Sometime you want to know how a Django ORM makes our queries execute or what is the corresponding SQL of the code you are writing. This is very strightforward. Youn can get str of any queryset.query to get the sql.

You have a model called Event. For getting all records, you will write something like Event.objects.all(), then do str(queryset.query)


>>> queryset = Event.objects.all()
>>> str(queryset.query)
SELECT "events_event"."id", "events_event"."epic_id",
"events_event"."details", "events_event"."years_ago"
FROM "events_event"



Example 2:

>>> queryset = Event.objects.filter(years_ago__gt=5)
>>> str(queryset.query)
SELECT "events_event"."id", "events_event"."epic_id", "events_event"."details",
"events_event"."years_ago" FROM "events_event"
WHERE "events_event"."years_ago" > 5


#python #django #orm
marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes.

- https://pypi.org/project/marshmallow/

#python #marshmallow #ORM #ODM