Skip to content

Commit 4479947

Browse files
author
Charles Lariviere
committed
docs(README): add missing references to using=metabase
Signed-off-by: Charles Lariviere <charles@dribbble.com>
1 parent 67c65a7 commit 4479947

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pip install metabase-python
1313
```
1414

1515
## Usage
16-
This API is still experimental and may change significantly between minor versions.
1716

17+
### Connection
1818

1919
Start by creating an instance of Metabase with your credentials.
2020
```python
@@ -27,6 +27,7 @@ metabase = Metabase(
2727
)
2828
```
2929

30+
### Interacting with Endpoints
3031
You can then interact with any of the supported endpoints through the classes included in this package. Methods that
3132
instantiate an object from the Metabase API require the `using` parameter which expects an instance of `Metabase` such
3233
as the one we just instantiated above. All changes are reflected in Metabase instantly.
@@ -84,27 +85,29 @@ my_group = PermissionGroup.create(name="My Group", using=metabase)
8485
for user in User.list():
8586
# add all users to my_group
8687
PermissionMembership.create(
87-
using=metabase,
8888
group_id=my_group.id,
89-
user_id=user.id
89+
user_id=user.id,
90+
using=metabase,
9091
)
9192
```
9293

94+
### Querying & MBQL
95+
9396
You can also execute queries and get results back as a Pandas DataFrame. You can provide the exact MBQL, or use
9497
the `Query` object to compile MBQL (i.e. Metabase Query Language) from Python classes included in this package.
9598

9699
```python
97100
from metabase import Dataset, Query, Count, GroupBy, TemporalOption
98101

99102
dataset = Dataset.create(
100-
using.metabase,
101103
database=1,
102104
type="query",
103105
query={
104106
"source-table": 1,
105107
"aggregation": [["count"]],
106108
"breakout": ["field", 7, {"temporal-unit": "year"},],
107109
},
110+
using=metabase,
108111
)
109112

110113
# compile the MBQL above using the Query object
@@ -116,6 +119,7 @@ dataset = Dataset.create(
116119
aggregations=[Count()],
117120
group_by=[GroupBy(id=7, option=TemporalOption.YEAR)]
118121
).compile(),
122+
using=metabase
119123
)
120124

121125
df = dataset.to_pandas()
@@ -174,7 +178,8 @@ metric = Metric.create(
174178
table_id=1,
175179
aggregations=[Count()],
176180
filters=[EndsWith(id=4, value="@gmail.com", option=CaseOption.CASE_INSENSITIVE)]
177-
).compile()
181+
).compile(),
182+
using=metabase
178183
)
179184
```
180185

0 commit comments

Comments
 (0)