Coder Social home page Coder Social logo

djarango's Introduction

djarango

ArangoDB Backend Interface for Django

Installation

$ pip install djarango
$ # check install status
$ djarango status

Configure settings.py (example)

DATABASES_ARANGO = {
    'default': {
        'ENGINE'       : 'django.db.backends.arangodb',# Backend implementation
        'NAME'         : 'graphdb',                 # DB name
        'HOST'         : 'localhost',               # Single-mode host; 'localhost' is default.
        'PORT'         : '8529',                    # Port 8529 is the default; optional.
        'USER'         : 'someuser',
        'PASSWORD'     : 'somepassword',
        'TIME_ZONE'    : 'UTC',
#       'USE_TZ'       : True,
        'CONN_MAX_AGE' : 60,
        'AUTOCOMMIT'   : True,
        # Arango supports clustered DB
        # If "HOSTS" is provided, it will override "HOST".
#       'HOSTS'     : [ '172.28.0.1', '172.28.0.2', '172.28.0.3', '172.28.0.4', ],
#       'HOST_RESOLVER' : 'rounrobin',      # Options are 'roundrobin' | 'random'
    }
}

Add Edge Fields to a Django model (example)

from django.db.backends.arangodb.fields.edges import EdgeField

# Djarango treats every Django model as an ArangoDB collection.
class ModelA(models.Model):
    title           = models.CharField(max_length = 50)
    description     = models.CharField(max_length = 200)
    counta          = models.IntegerField(default = 0)

    # EdgeField creates an edge from ModelA to ModelB
    # ModelA and ModelB are ArangoDB nodes, by default.
    # graph_name specifies the name of the graph that will be created in
    # ArangoDB containing the model (node) collections and edges.
    modelb          = EdgeField('ModelB', graph_name='ABTest')

class ModelB(models.Model):
    title           = models.CharField(max_length = 50)
    description     = models.CharField(max_length = 200)
    countb          = models.IntegerField(default = 0)

    # The EdgeFields are unidirectional.  In order to create a bidirectional
    # edge, there must be an EdgeField in each direction.
    # Specify the same graph_name so that the edges will be in the same graph.
    # Otherwise, a graph name will be auto-generated: 'graph_modelb_modela'
    # and each edge will be in different graphs.
    modela          = EdgeField('ModelA', graph_name='ABTest')

Design Notes

Additional information about design and the edge field implementation is in fields.md

djarango's People

Contributors

timothygraefe avatar

Stargazers

Constantin Sclifos avatar  avatar Mohamed El Habib Djamel ASLAOUI avatar K. N. avatar Yun Seong Kim avatar  avatar  avatar  avatar Sumit Kumar avatar Juan Carlos Rendon avatar

Watchers

 avatar

djarango's Issues

Collaboration/Feature Request: GIS Support

I am very interested in contributing to this project as I think this library's usage alongside something like Django Ninja is perfect for rapid microservice development. While I haven't done much tinkering under the hood, I have used Django extensively and ArangoDB to a lesser extent. Is there a roadmap for this project? I personally would like to see native GIS support added since that is arguably the most impressive feature of ArangoDB.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.