@@ -35,7 +35,10 @@ A few examples of the most common functionalities provided by the adapter:
3535import polypheny
3636
3737# Connect to Polypheny
38- connection = polypheny.connect(' localhost' , 20590 , username = ' pa' , password = ' ' )
38+ connection = polypheny.connect(' 127.0.0.1' , 20590 , username = ' pa' , password = ' ' , transport = ' plain' )
39+
40+ # If Python 3.8 is used the connection needs to bespecified as a tuple. Uncomment the following line
41+ # connection = polypheny.connect(('127.0.0.1', 20590), username='pa', password='', transport='plain')
3942
4043# Get a cursor
4144cursor = connection.cursor()
@@ -50,9 +53,30 @@ connection.commit()
5053# Execute a query
5154cursor.execute(" SELECT * from dummy" )
5255
56+ print (" \n Relational output from SQL" )
57+ print (" \t " ,cursor.fetchone())
58+
59+ # Accessing data using MQL
60+ cursor.executeany(' mongo' , ' db.dummy.find()' ,namespace = ' public' )
61+
62+ return_mql = cursor.fetchone()
63+ # json_output = json.loads( return_mql )
64+
65+
66+ print (" \n Plain JSON output from MQL" )
67+ print (" \t " ,return_mql)
68+
69+
70+
71+ print (" \n Plain JSON key 'text' from from MQL return" )
72+ print (" \t " ,return_mql[" text" ])
73+
74+
75+ cursor.execute(" DROP TABLE dummy" )
76+
5377# Print result
54- for f in cursor:
55- print (f)
78+ # for f in cursor:
79+ # print(f)
5680
5781# Close the connection
5882connection.close()
0 commit comments