Closed marcus011 closed 2 years ago
It’s been a while since I looked at odbc. Can you post links to both the working code and the pengines version? On Thu, Apr 28, 2022 at 3:57 AM Lakshay Sharma @.***> wrote:
Hi,
I was trying to interface ODBC with prolog using PostgreSQL, my predicates are working fine on command line tool (i.e using swipl), but when I host a prolog server on a port & access that port using python-pengines then I am start getting error messages Error communicating with planner: HTTP Error 500: Internal Server Error .
Please let me know how I can query ODBC commands using python-pengines
Thanks
— Reply to this email directly, view it on GitHub https://github.com/ian-andrich/PythonPengines/issues/24, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMMOJUHRRSNFXEB3KOCFTVHJVKPANCNFSM5USABHPQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
This is the code I am using for ODBC connection
using default server.pl from Git Readme
% test_database.pl
:- use_module(library(odbc)).
create_db_connect :-
odbc_connect('test', _,
[ alias(mydb),
open(once)
]).
disconnect_database :- odbc_disconnect(mydb).
I have created ODBC Data Source in /etc/odbc.ini
Earlier I was using swipl 8.4 & this error start appearing with pengines verison 0.1.8 (using python 2)
but after upgrading swipl to 8.5.10 , new error arised
Error:
Response string
{
"code":"permission_error",
"data":"No permission to call sandboxed `odbc_connect(_5598,_5600,_5602)'\nReachable from:\n\t '3b8aca44-102e-4832-b3de-1349e90941a4':create_db_connect",
"event":"error",
"id":"3b8aca44-102e-4832-b3de-1349e90941a4"
}
Error communicating with planner: Error - probably invalid Prolog query?
ah, it's sandboxed - so you need to explicitly permit this, this may help https://www.swi-prolog.org/pldoc/doc/_SWI_/library/pengines_sandbox.pl
apologies for brevity...
On Fri, Apr 29, 2022 at 3:49 AM Lakshay Sharma @.***> wrote:
This is the code I am using for ODBC connection
using default server.pl http://server.pl from Git Readme
% test_database.pl create_db_connect :- odbcconnect('test', , [ alias(mydb), open(once) ]).
disconnect_database :- odbc_disconnect(mydb).
I have created ODBC Data Source in /etc/odbc.ini
Earlier I was using swipl 8.4 & this error start appearing with pengines verison 0.1.8 (using python 2)
but after upgrading swipl to 8.5.10 , new error arised
Error:
Response string { "code":"permission_error", "data":"No permission to call sandboxed `odbc_connect(_5598,_5600,_5602)'\nReachable from:\n\t '3b8aca44-102e-4832-b3de-1349e90941a4':create_db_connect", "event":"error", "id":"3b8aca44-102e-4832-b3de-1349e90941a4" } Error communicating with planner: Error - probably invalid Prolog query?
— Reply to this email directly, view it on GitHub https://github.com/ian-andrich/PythonPengines/issues/24#issuecomment-1113167209, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMMOIIWGCKI3O4KRGOL3TVHO5CDANCNFSM5USABHPQ . You are receiving this because you commented.Message ID: @.***>
Thanks @cmungall for looking into it, can you help me out how I can utilize this sandboxed predicates, I don't know how to implement this.
Thanks
ah, it's sandboxed - so you need to explicitly permit this, this may help https://www.swi-prolog.org/pldoc/doc/_SWI_/library/pengines_sandbox.pl apologies for brevity...
Thanks alot for referencing me this url , I was able to interface my database using sandbox predicates & now I can easily interact with my db using python-pengines
I am adding my source code , so that it will help others
% test_database.pl
:- module(mydb,
[
create_db_connect/0,
disconnect_database/0
]
).
:- use_module(library(odbc)).
create_db_connect :-
odbc:odbc_connect('fleet_orchestrator', _,
[ alias(sqlobj),
open(once)
]).
disconnect_database :- odbc:odbc_disconnect(sqlobj).
:- multifile sandbox:safe_primitive/1.
sandbox:safe_primitive(mydb:create_db_connect).
sandbox:safe_primitive(mydb:disconnect_database).
/* if you have arguments in predicates, use _ (underscore)
example: sandbox:safe_primitive(mydb:query_database(_,_).
*/
Hi,
I was trying to interface ODBC with prolog using PostgreSQL, my predicates are working fine on command line tool (i.e using swipl), but when I host a prolog server on a port & access that port using python-pengines then I am start getting error messages
Error communicating with planner: HTTP Error 500: Internal server error append_args/3: Unknown procedure: '$messages':to_list/2
.Please let me know how I can query ODBC commands using python-pengines
Thanks