-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
25 lines (20 loc) · 941 Bytes
/
example_usage.py
File metadata and controls
25 lines (20 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""
Examples of using DataverseClient with different authentication methods.
"""
from DataversePython import DataverseClient
# Example 1: Interactive authentication (default)
# Requires user to sign in through browser
client_interactive = DataverseClient('sample_config.json')
# Or explicitly:
# client_interactive = DataverseClient('sample_config.json', auth_method='interactive')
# Example 2: Client secret authentication
# Uses application credentials for non-interactive authentication
client_secret = DataverseClient('sample_config_client_secret.json', auth_method='client_secret')
# Both clients can be used the same way:
# Get rows from an entity
accounts_df = client_interactive.get_rows('accounts', top=50)
print(f"Retrieved {len(accounts_df)} accounts")
# Insert rows
# client_interactive.insert_rows('accounts', new_accounts_df)
# Upsert rows
# client_secret.upsert_rows('contacts', contacts_df, primary_key_col='contactid')