Datasources
Each project is linked to datasources. Those datasources have 3 types: vertex
, simplifiedEdge
and cases
.
To access those we can do:
db1 = my_project.nodes_datasource # For vertex
db2 = my_project.edges_datasource # For simplifiedEdge
db3 = my_project.cases_datasource # For cases
Those datasources are Python objects that can be used to facilitate access to corresponding data. Once created, they are empty and need to be requested so that data can be fetched.
The easiest way to do this is to use the .load_dataframe()
method,
which is equivalent to a SELECT * FROM [datasource]
request.
Optionally, the load_limit
parameter can be used to fetch a subset of the dataframe.
This method returns a Pandas
Dataframe object.
df = db1.load_dataframe(load_limit=10) # load 10 rows of nodes_datasource
You can also return a list of all datasources associated with the workgroup. Note that in that case, all types of datasources are returned in the same list:
datasources_list = wg.datasources
If there are open connections, they can be closed if necessary:
wg = Workgroup(w_id, w_key, api_url, auth_url)
p = Project("<Your Project ID>", wg.api_connector)
ds = Datasource("<Your Datasource Name>", "<Your Datasource Type>", "<Your Host>", "<Your Port>", p)
ds.close()