-
Notifications
You must be signed in to change notification settings - Fork 0
/
pandas_example.py
59 lines (52 loc) · 1.93 KB
/
pandas_example.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import pandas as pd
# use for pip installation
import pytimbr as timbr
# use for repository installation
import pytimbr.timbr_connector as timbr
if __name__ == '__main__':
# Initiate a connection object
# General example
conn = timbr.getConnection(
hostname = '<TIMBR_IP/HOST>',
port = '<TIMBR_PORT>',
ontology = '<ONTOLOGY_NAME>',
username = '<TIMBR_USER/token>',
password = '<TIMBR_PASSWORD/TOKEN_VALUE>',
enabled_ssl = '<false/true>',
http_path = '<TIMBR_SERVER_HTTP_PATH>'
)
# hostname - The IP / Hostname of the Timbr server (not necessarily the hostname of the Timbr platform).
# port - The port to connect to in the Timbr server. Timbr's default port with enabled_ssl is 443 without SSL is 11000.
# ontology - the ontology / knowledge graph to connect to.
# username - Use 'token' as the username when connecting using a Timbr token, otherwise its the user name.
# password - Should be the token value if using a token as a username, otherwise its the user's password.
# enabled_ssl - true if SSL is enabled, false if SSL is disabled.
# http_path - Use only if your timbr server http path is not '/timbr-server'.
# HTTP example
conn = timbr.getConnection(
hostname = 'mytimbrenv.com',
port = '11000',
ontology = 'my_ontology',
username = 'timbr',
password = 'StrongPassword',
enabled_ssl = 'false',
http_path = '/timbr-server'
)
# HTTPS example
conn = timbr.getConnection(
hostname = 'mytimbrenv.com',
port = '443',
ontology = 'my_ontology',
username = 'timbr',
password = 'StrongPassword',
enabled_ssl = 'true',
http_path = '/timbr-server'
)
# Execute a query using Pandas
df = pd.read_sql("SELECT * FROM timbr.person limit 1000", conn)
print("--------------------------------------")
print(df)
print("--------------------------------------")
print(df.columns)
print("--------------------------------------")
print(df.count())