Package: pydangorm
Pydango - Asynchronous Pydantic ArangoDB ORMpydangormis a Python ORM (Object-Relational Mapping) system tailored forArangoDB, a multi-model NoSQL database. It provides a Pythonic interface for defining models, constructing queries, and interacting with ArangoDB, abstracting away the direct complexities of database interactions.FeaturesModel Definitions with pydantic(v1): Easily define and validate your database models usingpydantic.VertexModelEdgeModelPythonic Query Building: Construct complex ArangoDB queries with a Pythonic API.Session Management: Streamlined management of database sessions and connections.Collection Management: Create indices, truncate collections, and perform other collection operations.Asynchronous Support: Perform asynchronous database operations for optimized I/O-bound tasks.Full DocumentationInstallationpipinstallpydangormQuick Start & Usage ExamplesDefining ModelsUsingpydangorm, you can define vertex and edge models with ease:importdatetimefromtypingimportAnnotatedfrompydangoimport(EdgeModel,VertexModel,EdgeCollectionConfig,VertexCollectionConfig,Relation,)frompydango.indexesimportPersistentIndexclassVisited(EdgeModel):rating:inton_date:datetime.dateclassCollection(EdgeCollectionConfig):name="visited"indexes=[PersistentIndex(fields=["rating"]),]classLivesIn(EdgeModel):since:datetime.datetimeclassCollection(EdgeCollectionConfig):name="lives_in"classPerson(VertexModel):name:strage:intlives_in:Annotated["City",Relation[LivesIn]]visited:Annotated[list["City"],Relation[Visited]]classCollection(VertexCollectionConfig):name="people"indexes=[PersistentIndex(fields=["name"]),PersistentIndex(fields=["age"]),]classCity(VertexModel):name:strpopulation:intclassCollection(VertexCollectionConfig):name="cities"indexes=[PersistentIndex(fields=["name"]),PersistentIndex(fields=["population"]),]Querying DataConstruct and execute queries in a Pythonic manner:fromaioarangoimportArangoClientfromapp.modelsimportPerson,City,Visited,LivesInfrompydangoimportPydangoSessionfrompydango.ormimportfor_frompydango.connection.utilsimportget_or_create_db,deplete_cursorperson=Person(name="John",age=35,lives_in=City(name="Buenos Aires",population=30000000),visited=[City(name="Amsterdam",population=123),City(name="New Delhi",population=123),],edges={Person.lives_in:LivesIn(since=datetime.datetime.now()),Person.visited:[Visited(rating=10,on_date=datetime.date.today()),Visited(rating=10,on_date=datetime.date.today()),],},)asyncdefmain():db=awaitget_or_create_db(ArangoClient(),"app")session=PydangoSession(database=db)# Retrieving users older than 10 yearsawaitsession.save(person)assertperson.id.startswith("people/")db_person=awaitsession.get(Person,person.key,fetch_edges=True,depth=(1,1))assertdb_person==personquery=for_(Person).filter(Person.age>10).sort(-Person.age).return_(Person)query_result=awaitsession.execute(query)result=awaitdeplete_cursor(query_result)More detailed examples and scenarios can be found in thetestsdirectory, which showcases modeling and querying for different use-cases like cities, families, and e-commerce operations.Detailed DocumentationFor detailed documentation, please refer to thedocumentation.ContributingContributions topydangormare welcome! Please refer to theCONTRIBUTING.mdfile for guidelines.Licensepydangormis licensed underMIT. See theLICENSEfile for details.