GithubHelp home page GithubHelp logo

Adapter to OrientDB about web2py HOT 7 CLOSED

web2py avatar web2py commented on July 23, 2024
Adapter to OrientDB

from web2py.

Comments (7)

niphlod avatar niphlod commented on July 23, 2024

From [email protected] on September 16, 2011 11:40:51

-David Bloom

from web2py.

niphlod avatar niphlod commented on July 23, 2024

From [email protected] on December 16, 2011 08:26:59

Accepted. Which of the current adapters is the closest to the OrientDB syntax (sqlite, myqsl, postgresql, mssql?)

Status: Accepted

from web2py.

niphlod avatar niphlod commented on July 23, 2024

From [email protected] on December 17, 2011 08:16:37

The rest of the SQL syntax is very much like MySQL/Postgres. See: https://code.google.com/p/orient/wiki/SQL I see a potential problem in that OrientDB uses strings for its id field. I haven't looked recently but as I understand it the dbs in dal.py use integers as id. The OrientDB wiki will explain it better than I:

"RecordID

In OrientDB each record has a unique ID. The RecordID is composed in this way: #[:] Where:

cluster, is the cluster id. Positive numbers mean physical clusters. Negative numbers mean logical clusters.
position, is the absolute position of the record inside a cluster. 

NOTE: After the release 1.0rc4 the prefix character # is mandatory to recognize a RecordID.

The record never looses its identity unless is deleted. Once deleted its identity could be recycled and assigned to a new record. See the Inverse relationships to know more about this.

You can access directly to a record by knowing its RecordID. For this reason you don't need to create a field as primary key as happens in Relational DBMS. "

I hope the string as an ID issue can be overcome.

Not sure if it will help but I have had success in the meantime using the requests and ujson python libs to make HTTP requests to OrientDB's RESTful API and then .loads() the JSON response. There is a network binary protocol but I don't yet know how to have web2py and Orient communicate via binary.

It is an exciting prospect to combine web2py's flexibility with OrientDB's speed and analytical power. I think it would be amazing to not only have an adapter to web2py but also to have the communications somehow include running Gremlin graph traversals too.

Thanks again Massimo. I saw you so busy with the book and new versions and didn't think you'd get to my issue so soon. Do you ever sleep? :)

-David

from web2py.

niphlod avatar niphlod commented on July 23, 2024

From [email protected] on December 17, 2011 09:21:33

Can you point me to the function to obtain a new record id after a new record is inserted?

Do you ever sleep?
I did yesterday but I do not remember the previous time I did before yesteray. ;-)

Massimo

from web2py.

niphlod avatar niphlod commented on July 23, 2024

From [email protected] on December 17, 2011 10:10:25

Ha, glad you got at least one night's rest.

I wrote a little module which I used to parse the RID from the JSON result
of an INSERT.

Works great in /modules. Not sure if I need the from gluon import * bit
but left it as it was there when I created a new module.

/modules/orientdb_utils.py

#!/usr/bin/env python

coding: utf8

from gluon import *
import re

def RidFromInsert(resultstr):
regxrslt = re.search( '#\d+:\d+', resultstr )
return regxrslt.group(0)

Example of using requests, ujson and module to insert a record and retrieve
it's new RID.
This assumes a running OrientDB instance on the localhost with a database
called "web2pyrules" and has a schema that has a cluster called Category
Think of OrientDB cluster = MySQL table. A way to group information except
it can be schema-full/mixed/less

import requests
import ujson as json # Faster JSON
from orientdb_utils import RidFromInsert

r = requests.post('http://localhost:2480/command/web2pyrules/sql'
data="INSERT INTO Category (name) VALUES ('web2py')", auth=('writer',
'writer'))
result = json.loads(r.content)
cat_id = RidFromInsert(result)

I don't know if it would be useful but I also wrote a module to add/remove
in/out edges to a vertex when using OrientDB as a document-graph db. It
also uses the RESTful API similar to above.

from web2py.

niphlod avatar niphlod commented on July 23, 2024

From [email protected] on August 07, 2012 19:46:43

Labels: -Type-Defect Type-Enhancement

from web2py.

cassiobotaro avatar cassiobotaro commented on July 23, 2024

@niphlod Moved to web2py/pydal#321. Can you close this?

from web2py.

Related Issues (20)

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.