Re: [orientdb] OrientDB sql query involving multiple classes
Yeahh!! it worked. Really thanks about that. "databasename": { "mapping": { "fromTable": "source table", "fromColumns": ["source field"], "toTable": "destination table", "toColumns": ["destination table"], "direction": "direct" } } Also i found this on the internet about mapping or creating relation , but i couldn't find anything about it in documentation. M i missing something? Or what is the topic name of this code line? Or simply is this code line true? Regards Ersin 28 Mart 2018 Çarşamba 10:33:45 UTC+3 tarihinde Luigi Dell'Aquila yazdı: > > Hi Ersin, > > The problem seems to be in the python driver, did you try to run the > queries in Studio and see if they work fine? > > If you are using OrientDB v 3.0 RC you can write a query as follows: > > MATCH >{class:Company, as:company} <-PersonnelRelation- {as:person} > RETURN company:{*}, person:{*} > > This is kind of an inner join based on PersonnelRelation. You can also > add WHERE conditions to the pattern to filter the result, see > http://orientdb.com/docs/3.0.x/sql/SQL-Match.html > > Thanks > > Luigi > > > 2018-03-25 12:48 GMT+02:00 Ersin Sevinc> : > >> Thanks alot Luigi. You guys are really helping all developers. But i' ve >> an extra question for you :/ >> >> We have some problems about OrientObject is not Json serializable Error. >> >> Let me explain our code in simple way. We have >> Customers,Admins(Company),Product,Personel classes and CRUD for all of >> them in back end (Python). >> >> HERE IS MY VERTEX >> >> createPersonel = configDb.client.command("create vertex PersonelInformation >> set Adress ='" + adress >> + "',""CitizenId='" + citizenId + >> "',CompanyCode='" + companyCode >> + "',""Email='" + email + >> "',Name='" + name + "', Surname='" + surname >> + "',Phone=" + phone) >> >> >> >> >> HERE IS MY EDGE >> >> createRelation = configDb.client.command("create edge PersonelRelation from >> " + personelRid + " to " + companyRid + "' ") >> --- >> >> SELECT QUERY FOR ALL INFORMATIONS IN CLASS >> >> all = [] >> data = configDb.client.command("select * from PersonelInformation") >> for i in range(0, len(data)): >> all.append(data[i].oRecordData) >> return json.dumps(all) >> >> >> >> >> - >> >> Everything is fine except select query, I can not see the relationship. >> When there is a relation in some records , after execute the query i get >> this error . >> >> [2018-03-25 13:24:49,575] ERROR in app: Exception on /personelInfo/getAll >> [GET] >> Traceback (most recent call last): >> File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line >> 1982, in wsgi_app >> response = self.full_dispatch_request() >> File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line >> 1614, in full_dispatch_request >> rv = self.handle_user_exception(e) >> File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line >> 1517, in handle_user_exception >> reraise(exc_type, exc_value, tb) >> File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\_compat.py", >> line 33, in reraise >> raise value >> File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line >> 1612, in full_dispatch_request >> rv = self.dispatch_request() >> File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line >> 1598, in dispatch_request >> return self.view_functions[rule.endpoint](**req.view_args) >> File "D:/Outputs/pyCharm/rms\Middleware\Decator.py", line 16, in >> decorated_function >> return f(*args, **kwargs) >> File "D:/Outputs/pyCharm/rms\Resources\PersonelinformationResource.py", >> line 105, in GetAll >> return re >> File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\json.py", >> line 123, in dumps >> rv = _json.dumps(obj, **kwargs) >> File "D:\Program Files\Python36\Lib\json\_init_.py", line 238, in dumps >> **kw).encode(obj) >> File "D:\Program Files\Python36\Lib\json\encoder.py", line 199, in >> encode >> chunks = self.iterencode(o, _one_shot=True) >> File "D:\Program Files\Python36\Lib\json\encoder.py", line 257, in >> iterencode >> return _iterencode(o, 0) >> File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\json.py", >> line 80, in default >> return _json.JSONEncoder.default(self, o) >> File "D:\Program Files\Python36\Lib\json\encoder.py", line 180, in >> default >> o._class.name_)
Re: [orientdb] OrientDB sql query involving multiple classes
Hi Ersin, The problem seems to be in the python driver, did you try to run the queries in Studio and see if they work fine? If you are using OrientDB v 3.0 RC you can write a query as follows: MATCH {class:Company, as:company} <-PersonnelRelation- {as:person} RETURN company:{*}, person:{*} This is kind of an inner join based on PersonnelRelation. You can also add WHERE conditions to the pattern to filter the result, see http://orientdb.com/docs/3.0.x/sql/SQL-Match.html Thanks Luigi 2018-03-25 12:48 GMT+02:00 Ersin Sevinc: > Thanks alot Luigi. You guys are really helping all developers. But i' ve > an extra question for you :/ > > We have some problems about OrientObject is not Json serializable Error. > > Let me explain our code in simple way. We have > Customers,Admins(Company),Product,Personel > classes and CRUD for all of them in back end (Python). > > HERE IS MY VERTEX > > createPersonel = configDb.client.command("create vertex PersonelInformation > set Adress ='" + adress > + "',""CitizenId='" + citizenId + > "',CompanyCode='" + companyCode > + "',""Email='" + email + "',Name='" > + name + "', Surname='" + surname > + "',Phone=" + phone) > > > > > > HERE IS MY EDGE > > createRelation = configDb.client.command("create edge PersonelRelation from " > + personelRid + " to " + companyRid + "' ") > --- > > SELECT QUERY FOR ALL INFORMATIONS IN CLASS > > all = [] > data = configDb.client.command("select * from PersonelInformation") > for i in range(0, len(data)): > all.append(data[i].oRecordData) > return json.dumps(all) > > > > > - > > Everything is fine except select query, I can not see the relationship. > When there is a relation in some records , after execute the query i get > this error . > > [2018-03-25 13:24:49,575] ERROR in app: Exception on /personelInfo/getAll > [GET] > Traceback (most recent call last): > File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line > 1982, in wsgi_app > response = self.full_dispatch_request() > File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line > 1614, in full_dispatch_request > rv = self.handle_user_exception(e) > File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line > 1517, in handle_user_exception > reraise(exc_type, exc_value, tb) > File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\_compat.py", > line 33, in reraise > raise value > File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line > 1612, in full_dispatch_request > rv = self.dispatch_request() > File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line > 1598, in dispatch_request > return self.view_functions[rule.endpoint](**req.view_args) > File "D:/Outputs/pyCharm/rms\Middleware\Decator.py", line 16, in > decorated_function > return f(*args, **kwargs) > File "D:/Outputs/pyCharm/rms\Resources\PersonelinformationResource.py", > line 105, in GetAll > return re > File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\json.py", > line 123, in dumps > rv = _json.dumps(obj, **kwargs) > File "D:\Program Files\Python36\Lib\json\_init_.py", line 238, in dumps > **kw).encode(obj) > File "D:\Program Files\Python36\Lib\json\encoder.py", line 199, in > encode > chunks = self.iterencode(o, _one_shot=True) > File "D:\Program Files\Python36\Lib\json\encoder.py", line 257, in > iterencode > return _iterencode(o, 0) > File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\json.py", > line 80, in default > return _json.JSONEncoder.default(self, o) > File "D:\Program Files\Python36\Lib\json\encoder.py", line 180, in > default > o._class.name_) > TypeError: Object of type 'OrientBinaryObject' is not JSON serializable > 127.0.0.1 - - [25/Mar/2018 13:24:49] "GET /personelInfo/getAll HTTP/1.1" > 500 - > > > > --- > IN THE OTHER HAND, When i delete records with relations , My Select query > works fine. I can see all records without relation. > But my main goal is getting companyCode when i query on > PersonelInformation vertex. > > > Also i tried This. > > -select adress from user where = out('PersonelRelation')[0].name = > "orient" > > >
Re: [orientdb] OrientDB sql query involving multiple classes
Thanks alot Luigi. You guys are really helping all developers. But i' ve an extra question for you :/ We have some problems about OrientObject is not Json serializable Error. Let me explain our code in simple way. We have Customers,Admins(Company),Product,Personel classes and CRUD for all of them in back end (Python). HERE IS MY VERTEX createPersonel = configDb.client.command("create vertex PersonelInformation set Adress ='" + adress + "',""CitizenId='" + citizenId + "',CompanyCode='" + companyCode + "',""Email='" + email + "',Name='" + name + "', Surname='" + surname + "',Phone=" + phone) HERE IS MY EDGE createRelation = configDb.client.command("create edge PersonelRelation from " + personelRid + " to " + companyRid + "' ") --- SELECT QUERY FOR ALL INFORMATIONS IN CLASS all = [] data = configDb.client.command("select * from PersonelInformation") for i in range(0, len(data)): all.append(data[i].oRecordData) return json.dumps(all) - Everything is fine except select query, I can not see the relationship. When there is a relation in some records , after execute the query i get this error . [2018-03-25 13:24:49,575] ERROR in app: Exception on /personelInfo/getAll [GET] Traceback (most recent call last): File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\_compat.py", line 33, in reraise raise value File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "D:/Outputs/pyCharm/rms\Middleware\Decator.py", line 16, in decorated_function return f(*args, **kwargs) File "D:/Outputs/pyCharm/rms\Resources\PersonelinformationResource.py", line 105, in GetAll return re File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\json.py", line 123, in dumps rv = _json.dumps(obj, **kwargs) File "D:\Program Files\Python36\Lib\json\_init_.py", line 238, in dumps **kw).encode(obj) File "D:\Program Files\Python36\Lib\json\encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "D:\Program Files\Python36\Lib\json\encoder.py", line 257, in iterencode return _iterencode(o, 0) File "D:\Outputs\pyCharm\rms\venv\lib\site-packages\flask\json.py", line 80, in default return _json.JSONEncoder.default(self, o) File "D:\Program Files\Python36\Lib\json\encoder.py", line 180, in default o._class.name_) TypeError: Object of type 'OrientBinaryObject' is not JSON serializable 127.0.0.1 - - [25/Mar/2018 13:24:49] "GET /personelInfo/getAll HTTP/1.1" 500 - --- IN THE OTHER HAND, When i delete records with relations , My Select query works fine. I can see all records without relation. But my main goal is getting companyCode when i query on PersonelInformation vertex. Also i tried This. -select adress from user where = out('PersonelRelation')[0].name = "orient" OUT comes like this. b64:'AQEAggAA' IN SHORT my main problem is when i connect the Company And Personel Classes, i want to see Company class informations over personelInformation Query. But i dont want to restrict my query like , select from where rid = 37 i just want to get company information wihtout giving any company information in Personel Query. Just want to get informations about Company in Back end and want to read them. Its not important after a query like = select from personel where CompanyCode "abc" Really Thanks alot from now Looking for your answer Regards, Ersin 5 Mart 2018 Pazartesi 12:21:40 UTC+3 tarihinde Luigi Dell'Aquila yazdı: > > Hi Ersin, > > There is no SQL statement to do this, but
Re: [orientdb] OrientDB sql query involving multiple classes
Hi there, m new at orient db trying to figure out something about relations , In this code Line => create edge owns from (select from Person where name = 'Matt') to (select from Car where model = 'Ferrari') We have edge between record to record. Its fine for few records. But what will happen if i ve millions of data ? Should i create edge from backend for every new record? Or can i just link the Property Fields like => create edge owns from Person.Name to Car.model ?? I want to know that is there any possible way for relation database like MSSQL , you know in ms sql , we can create PK and FK between Fields , with that way we do not need to create relations for every new record. Here another question -> select car.model person.name from car, person Where .. I think i can not use 2 different class after FROM m i right ? 27 Mart 2014 Perşembe 17:03:33 UTC+3 tarihinde Andrey Lomakin yazdı: > > Hi, > Could you try > > select name from Person where gender = 'M' and out('owns')[0].model = > "Ferrari" and out('likes')[0].mov_name = "Need For Speed" > > > On Thu, Mar 27, 2014 at 5:13 AM, Joel Mathew> wrote: > >> Hi group, >> I have below schema with three classes >> >> orientdb {demo1}> select from Person >> +-+-+--++- >> # |@RID |name |gender|out_owns|out_likes >> +-+-+--++- >> 0 |#11:0|Matt |M |#12:0 |#13:0 >> 1 |#11:1|Helen|F |#12:1 |#13:1 >> +-+-+--++- >> >> orientdb {demo1}> select from Car >> +-+---+--- >> # |@RID |model |in_owns >> +-+---+--- >> 0 |#12:0|Ferrari|#11:0 >> 1 |#12:1|BMW|#11:1 >> +-+---+--- >> >> orientdb {demo1}> select from Movie >> +-+--+ >> # |@RID |mov_name |in_likes >> +-+--+ >> 0 |#13:0|Need For Speed|#11:0 >> 1 |#13:1|Matrix|#11:1 >> +-+--+ >> >> Person(name,gender) >> Car(model) >> Movie(mov_name) >> Person > owns > Car >> Person > likes > Movie >> >> I'm looking at a query which matches values across three classes across >> the edges >> Find Person.name where Person.gender='M' and who owns Car.model='Ferrari' >> and who likes Movie.mov_name='Need For Speed' >> >> One way to achieve the same with gremlin is >> g.V('@class','Car').has('model','Ferrari').in('owns').has('@class','Person').has('gender','M').as('x').out('likes').has('@class','Movie').has('mov_name','Need >> >> For Speed').select(["x"]) >> I'm using OrientDB 1.7-rc2-SNAPSHOT.. >> Please help me with some pointers towards equivalent orientdb sql. >> >> Thanks, >> Mathew >> >> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "OrientDB" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to orient-databa...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Best regards, > Andrey Lomakin. > > Orient Technologies > the Company behind OrientDB > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [orientdb] OrientDB SQL
Hi Luigi, thank you! That was the problem. Regards, Hans. Am Dienstag, 22. November 2016 12:21:28 UTC+1 schrieb Luigi Dell'Aquila: > > Hi, > > by default OrientDB Studio Graph panel displays only 20 records. You can > override this behavior adding a "limit" at the end of the query, eg. > > SELECT FROM V LIMIT -1 > > Thanks > > Luigi > > 2016-11-22 12:03 GMT+01:00 'Hans-Jürgen Otto' via OrientDB < > orient-...@googlegroups.com >: > >> Hey guys, >> >> I use a modified version of Teva-Gremlin ( >> https://github.com/effyteva/CSharpLibraries/tree/master/Teva.Common.Data.Gremlin) >> >> with Gremlin-Server (3.2.3) that is connected to OrientDB (with >> OrientDB-Gremlin https://github.com/orientechnologies/orientdb-gremlin). >> I've created a graph and the creation went off normal. >> So i wanted to get some Data in OrientStudio. First I used Gremlin and i >> got all vertices that i wanted. Then i used this SQL-Like query-language >> from OrientDB and i got only a part of the vertices that i wanted. >> For instance: >> I used "*g.V()*" and got all 221 vertices. >> Then i used SELECT FROM V and got only 20 vertices. >> However if I count all vertices with SELECT COUNT(*) FROM V I get the >> right number 221. >> Am I missing something? >> >> Regards >> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "OrientDB" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to orient-databa...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [orientdb] OrientDB SQL
Hi, by default OrientDB Studio Graph panel displays only 20 records. You can override this behavior adding a "limit" at the end of the query, eg. SELECT FROM V LIMIT -1 Thanks Luigi 2016-11-22 12:03 GMT+01:00 'Hans-Jürgen Otto' via OrientDB < orient-database@googlegroups.com>: > Hey guys, > > I use a modified version of Teva-Gremlin (https://github.com/effyteva/ > CSharpLibraries/tree/master/Teva.Common.Data.Gremlin) with Gremlin-Server > (3.2.3) that is connected to OrientDB (with OrientDB-Gremlin > https://github.com/orientechnologies/orientdb-gremlin). > I've created a graph and the creation went off normal. > So i wanted to get some Data in OrientStudio. First I used Gremlin and i > got all vertices that i wanted. Then i used this SQL-Like query-language > from OrientDB and i got only a part of the vertices that i wanted. > For instance: > I used "*g.V()*" and got all 221 vertices. > Then i used SELECT FROM V and got only 20 vertices. > However if I count all vertices with SELECT COUNT(*) FROM V I get the > right number 221. > Am I missing something? > > Regards > > -- > > --- > You received this message because you are subscribed to the Google Groups > "OrientDB" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to orient-database+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [orientdb] Orientdb SQL query to check edge properties
Hi, for sensors I would say: SELECT FROM Sensor WHERE isDeleted = true AND 1 in in('DeviceHasSensors').in('UserHasDevices').userId For devides it's simpler: SELECT FROM Device WHERE isDeleted = true AND 1 in in('UserHasDevices').userId Cheers, Riccardo 2015-07-13 23:25 GMT+02:00 Yasith Lokuge yasi...@gmail.com: I have a Graph database with three simple Vertex types, User, Device and Sensor. The relationship goes as, Edges: UserHasDevices, DeviceHasSensors Each edge has a property name isDeleted. When deleting a Vertex, I don't make it deleted permanently but make the isDeleted property of the Edge as true. Please let me know How to query a list of deleted sensors, and / or deleted list of devices, which belongs to a particular user, identified by user id. -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [orientdb] OrientDB sql query involving multiple classes
Hi, Could you try select name from Person where gender = 'M' and out('owns')[0].model = Ferrari and out('likes')[0].mov_name = Need For Speed On Thu, Mar 27, 2014 at 5:13 AM, Joel Mathew meetj...@gmail.com wrote: Hi group, I have below schema with three classes orientdb {demo1} select from Person +-+-+--++- # |@RID |name |gender|out_owns|out_likes +-+-+--++- 0 |#11:0|Matt |M |#12:0 |#13:0 1 |#11:1|Helen|F |#12:1 |#13:1 +-+-+--++- orientdb {demo1} select from Car +-+---+--- # |@RID |model |in_owns +-+---+--- 0 |#12:0|Ferrari|#11:0 1 |#12:1|BMW|#11:1 +-+---+--- orientdb {demo1} select from Movie +-+--+ # |@RID |mov_name |in_likes +-+--+ 0 |#13:0|Need For Speed|#11:0 1 |#13:1|Matrix|#11:1 +-+--+ Person(name,gender) Car(model) Movie(mov_name) Person owns Car Person likes Movie I'm looking at a query which matches values across three classes across the edges Find Person.name where Person.gender='M' and who owns Car.model='Ferrari' and who likes Movie.mov_name='Need For Speed' One way to achieve the same with gremlin is g.V('@class','Car').has('model','Ferrari').in('owns').has('@class','Person').has('gender','M').as('x').out('likes').has('@class','Movie').has('mov_name','Need For Speed').select([x]) I'm using OrientDB 1.7-rc2-SNAPSHOT.. Please help me with some pointers towards equivalent orientdb sql. Thanks, Mathew -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Best regards, Andrey Lomakin. Orient Technologies the Company behind OrientDB -- --- You received this message because you are subscribed to the Google Groups OrientDB group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.