Skip to content

Commit 7794722

Browse files
committed
Update README.md
1 parent 5e66ed1 commit 7794722

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

README.md

+19-27
Original file line numberDiff line numberDiff line change
@@ -34,57 +34,49 @@ A few examples of the most common functionalities provided by the adapter:
3434
```python3
3535
import 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
4752
cursor.execute("CREATE TABLE dummy (id INT NOT NULL, text VARCHAR(2), num INT, PRIMARY KEY(id))")
4853

4954
# Insert values into table
5055
cursor.execute("INSERT INTO dummy VALUES (407 , 'de', 93)")
51-
connection.commit()
56+
con.commit()
5257

5358
# Execute a query
5459
cursor.execute("SELECT * from dummy")
5560

56-
print("\nRelational output from SQL")
57-
print("\t",cursor.fetchone())
61+
print("\nRelational 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("\nPlain JSON output from MQL")
67-
print("\t",return_mql)
68-
69-
70-
71-
print("\nPlain 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("\nDocument results from MQL (as Python dicts)")
69+
for doc in cursor:
70+
print("\t", doc)
7471

7572
cursor.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

8578
An in-depth and more detailed documentation can be found [here](https://docs.polypheny.com/en/latest/drivers/python/overview).
8679

87-
8880
## Tests
8981
Run the tests with coverage report:
9082
```

0 commit comments

Comments
 (0)