# Accessing clinical records using almirah This tutorial will guide you through the process of accessing clinical records from the CALM Brain Resource using the `almirah` Python library. ## Connecting to the Database First, we'll import the necessary library and connect to the database. ```python from almirah import Database ``` Create a database instance with the specified name, host, and backend: ```python db = Database(name="calm-brain", host="https://calm-brain.ncbs.res.in/db-request/", backend="request") db ``` This should output: ## Querying the Database Next, we connect to the database using credentials: ```python db.connect("username", "password") ``` Now, let's query a specific table, such as `presenting_disorders`, and display some of the data: ```python df = db.query(table="presenting_disorders") df[["subject", "session", "addiction"]].head() ``` This displays the first few rows of the queried table in a DataFrame format:
subject session addiction
0 D0019 101 0
1 D0019 111 0
2 D0020 101 0
3 D0020 111 <NA>
4 D0021 101 0
We can also get the total number of records in the table: ```python len(df) ``` This returns the total number of records: 2561 Lastly, let's find the number of records where addiction is noted: ```python len(df[df["addiction"] == 1]) ``` This gives us the count of records with addiction: 522 This concludes the tutorial. You've learned how to connect to a database, query its tables, and analyze the data using the `almirah` library.