Here you can find the official Python driver for the MillenniumDB server.
Check out the driver for different languages!
📦millenniumdb_driver
├── 📂docs/ ---------------------------- Documentation generator (Sphinx)
├── 📂src/ ----------------------------- The Python implementation
├── 📜LICENSE
├── 📜README.md
├── 📜pyproject.toml
└── 📜setup.cfg
Dependencies:
- Git
- Setuptools
- Wheel
- A running MillenniumDB server instance
Install the driver and the dependecies.
pip install millenniumdb_driver
After successfully installing the project, you can start using the library in your Python programs.
First you must create a Driver
instance:
import millenniumdb_driver
url = 'URL for the MillenniumDB server'
driver = millenniumdb_driver.driver(url)
When you are done with the driver, you should close it before exiting the application.
driver.close()
For sending queries to the MillenniumDB server, you must acquire a session instance:
session = driver.session()
Then you can send queries through your session.
query = 'MATCH (?from)-[:?type]->(?to) RETURN * LIMIT 10'
result = session.run(query)
The alternatives for consuming results must never be mixed because it would generate undefined behavior on your client and/or server. It is important to mention that the session must be closed when your operations are done.
result.variables() -> Tuple[str]
Returns the list of variables in the result.
result.records() -> List[Record]
Returns the list of Records
in the result.
result.values() -> List[object]
Returns the list of values in the result.
result.data() -> List[Dict[str, object]]
Returns the list of records in the result as dictionaries.
result.to_df() -> "DataFrame"
Returns the result as a Pandas DataFrame.
result.summary() -> object
Returns the summary of the result.
for record in result: -> Iterator[Record]
print(record)
Iterates over each record in result.