Kwil v2
Search…
⌃K

Get Databases and Schemas

Methods to view databases owned by an address and the schemas within each database.
You can view the databases owned by an address by using the listDatabases method. This returns an array of the databases under the provided address.
const res = await kwil.listDatabases("owner_address")
// res.data = ["db1", "db2", "db3"]
You can get the schema of a database by using the getSchema method on the Kwil object. This returns a JSON representation of the database schema. For more information on the JSON representation, see the Database documentation.
const res = await kwil.getSchema("0xOwner_address", "database_name")
/*
res.data = {
name: "database_name",
owner: "0xowner_address",
tables: [ tableObject1, tableObject2, tableObject3 ]
sqlQueries: [ sqlQueryObject1, sqlQueryObject2, sqlQueryObject3 ]
roles: [ roleObject1, roleObject2, roleObject3 ]
indexes: [ indexObject1, indexObject2, indexObject3 ]
}
*/