Skip to main content


You can easily install the latest Kùzu Python API using pip: pip install kuzu.

Once the Python API is installed, you'll be able to import it in Python and execute Cypher queries. Below is a brief demonstration on getting started. You can find detailed information on the Python API here.

  • Import library:
import kuzu
  • Create an empty database and connect to it with Python API:
db = kuzu.Database('./test')
conn = kuzu.Connection(db)
  • Define the schema:
conn.execute("CREATE NODE TABLE User(name STRING, age INT64, PRIMARY KEY (name))")
conn.execute("CREATE NODE TABLE City(name STRING, population INT64, PRIMARY KEY (name))")
conn.execute("CREATE REL TABLE Follows(FROM User TO User, since INT64)")
conn.execute("CREATE REL TABLE LivesIn(FROM User TO City)")
  • Load data:
conn.execute('COPY User FROM "user.csv"')
conn.execute('COPY City FROM "city.csv"')
conn.execute('COPY Follows FROM "follows.csv"')
conn.execute('COPY LivesIn FROM "lives-in.csv"')
  • Execute a simple query:
results = conn.execute('MATCH (u:User) RETURN, u.age;')
while results.has_next():


['Adam', 30]
['Karissa', 40]
['Zhang', 50]
['Noura', 25]

Alternatively, the Python API can also output results as a Pandas data frame:

results = conn.execute('MATCH (a:User)-[f:Follows]->(b:User) RETURN, f.since,;').get_as_df()

Output:  f.since
0 Adam 2020 Karissa
1 Adam 2020 Zhang
2 Karissa 2021 Zhang
3 Zhang 2022 Noura

Moreover, you can output results in the Arrow format:

results = conn.execute('MATCH (u:User) RETURN, u.age;')

Output: string
u.age: int64
---- [["Adam","Karissa","Zhang","Noura"]]
u.age: [[30,40,50,25]]

Colab Notebooks

We've compiled a series of Google Colab notebooks that demonstrate how Kùzu can be used through Python APIs, and integrated with the Python data science ecosystem: