@@ -34,57 +34,49 @@ A few examples of the most common functionalities provided by the adapter:
3434``` python3
3535import polypheny
3636
37- # Connect to Polypheny
38- connection = polypheny.connect(' 127.0.0.1 ' , 20590 , username = ' pa ' , password = ' ' , transport = ' plain ' )
37+ # Connect to locally running Polypheny via UNIX sockets (on Linux, BSD and macOS)
38+ con = polypheny.connect()
3939
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')
40+ # Unencrypted over the network (all systems)
41+ con = polypheny.connect(
42+ (' 127.0.0.1' , 20590 ),
43+ username = ' pa' ,
44+ password = ' ' ,
45+ transport = ' plain' ,
46+ )
4247
4348# Get a cursor
44- cursor = connection .cursor()
49+ cursor = con .cursor()
4550
4651# Create a new table
4752cursor.execute(" CREATE TABLE dummy (id INT NOT NULL, text VARCHAR(2), num INT, PRIMARY KEY(id))" )
4853
4954# Insert values into table
5055cursor.execute(" INSERT INTO dummy VALUES (407 , 'de', 93)" )
51- connection .commit()
56+ con .commit()
5257
5358# Execute a query
5459cursor.execute(" SELECT * from dummy" )
5560
56- print (" \n Relational output from SQL" )
57- print (" \t " ,cursor.fetchone())
61+ print (" \n Relational results from SQL" )
62+ for row in cursor:
63+ print (" \t " , row)
5864
5965# 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" ])
66+ cursor.executeany(' mongo' , ' db.dummy.find()' , namespace = ' public' )
7367
68+ print (" \n Document results from MQL (as Python dicts)" )
69+ for doc in cursor:
70+ print (" \t " , doc)
7471
7572cursor.execute(" DROP TABLE dummy" )
7673
77- # Print result
78- # for f in cursor:
79- # print(f)
80-
8174# Close the connection
82- connection .close()
75+ con .close()
8376```
8477
8578An in-depth and more detailed documentation can be found [ here] ( https://docs.polypheny.com/en/latest/drivers/python/overview ) .
8679
87-
8880## Tests
8981Run the tests with coverage report:
9082```
0 commit comments