@@ -35,7 +35,10 @@ A few examples of the most common functionalities provided by the adapter:
35
35
import polypheny
36
36
37
37
# 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')
39
42
40
43
# Get a cursor
41
44
cursor = connection.cursor()
@@ -50,9 +53,30 @@ connection.commit()
50
53
# Execute a query
51
54
cursor.execute(" SELECT * from dummy" )
52
55
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
+
53
77
# Print result
54
- for f in cursor:
55
- print (f)
78
+ # for f in cursor:
79
+ # print(f)
56
80
57
81
# Close the connection
58
82
connection.close()
0 commit comments