Re: [orientdb] OrientDB sql query involving multiple classes

2018-03-28 Thread Ersin Sevinc
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_)
>> TypeError: Object

Re: [orientdb] OrientDB sql query involving multiple classes

2018-03-28 Thread Luigi Dell'Aquila
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"
>
> 
> 
>
> OUT comes like t