In [1]:
# hide ssl warnings for this test.
import requests
requests.packages.urllib3.disable_warnings()

Accessing multiple data sources with python-fmrest

This is a short example on how to access data from multiple data sources.

Import the module


In [2]:
import fmrest

Create the server instance

Create the Server instance as usual, but pass a list of all databases, including credentials, you want to access during your session:


In [3]:
fms = fmrest.Server('https://10.211.55.15',
                    user='admin',
                    password='admin',
                    database='Contacts',
                    layout='Contacts',
                    verify_ssl=False,
                    data_sources=[{'database': 'SecondDataSource', 'username': 'admin2', 'password': 'admin2'}]
                   )

Login

The login method obtains the access token.


In [4]:
fms.login()


Out[4]:
'3dadadbf13d06b2cfec2a5d6470b09f990504e1a0c3dcbc13ad4'

Access the data as usual

Now you can access records from TOs based on tables from external database files. Be it directly or via a portal.


In [5]:
record = fms.get_record(1)
record['portal_secondDataSource'][0]['SecondDataSource::name']


Out[5]:
'David'

Logout

Be nice and do your cleanup :-)


In [6]:
fms.logout()


Out[6]:
True