Create Local Database from Static Copy of AACT

If you would like to work with the complete set of clinical trials on your own computer... install PostgreSQL locally, download a static copy of the AACT database, and populate a local PostgreSQL AACT database instance with the data. This page provides the instructions.

Windows Users: Click here for step-by-step instructions to install PostgreSQL & create/load a local copy of AACT on a Windows machine.

1

Install PostgreSQL Database Platform

The PostgreSQL package (open source and freely available) includes a number of nice tools. If you intend to access the public AACT database hosted in the cloud, the only PostgreSQL tool you need is psql. If you would like to download a static copy of AACT to use on your local machine, you'll need the full postgreSQL package including the tools to create and populate the database (createdb & pg_restore). These tools are part of the standard PostgreSQL package, so once installed, you will be able to create your own AACT database.

AACT is currently running on version 9.6.6 of PostgreSQL; it's recommended you install this version or higher. You many download PostgreSQL from the PostgreSQL Download Site or this Enterprise DB site.

We've provided a few screenshots and basic instructions here to help guide you through the installation process.

2

Download Package Containing Static Copy of AACT Database

Download a zip file that contains the AACT database file. With a single command (see below), this file can be used to automatically configure the database & populate it with the clinical trials dataset. The zip file also contains documentation that describes the database at the time the static copy was created. (The download typically takes 3-7 minutes, depending on your network speed.)

Current Month's Daily Static Copies

[{:name=>"20180922_clinical_trials.zip", :date_created=>"09/22/2018", :size=>"823 MB", :url=>"/static/static_db_copies/daily/20180922_clinical_trials.zip"}, {:name=>"20180921_clinical_trials.zip", :date_created=>"09/21/2018", :size=>"822 MB", :url=>"/static/static_db_copies/daily/20180921_clinical_trials.zip"}, {:name=>"20180920_clinical_trials.zip", :date_created=>"09/20/2018", :size=>"822 MB", :url=>"/static/static_db_copies/daily/20180920_clinical_trials.zip"}, {:name=>"20180919_clinical_trials.zip", :date_created=>"09/19/2018", :size=>"821 MB", :url=>"/static/static_db_copies/daily/20180919_clinical_trials.zip"}, {:name=>"20180918_clinical_trials.zip", :date_created=>"09/18/2018", :size=>"820 MB", :url=>"/static/static_db_copies/daily/20180918_clinical_trials.zip"}, {:name=>"20180916_clinical_trials.zip", :date_created=>"09/16/2018", :size=>"820 MB", :url=>"/static/static_db_copies/daily/20180916_clinical_trials.zip"}, {:name=>"20180915_clinical_trials.zip", :date_created=>"09/15/2018", :size=>"819 MB", :url=>"/static/static_db_copies/daily/20180915_clinical_trials.zip"}, {:name=>"20180914_clinical_trials.zip", :date_created=>"09/14/2018", :size=>"819 MB", :url=>"/static/static_db_copies/daily/20180914_clinical_trials.zip"}, {:name=>"20180913_clinical_trials.zip", :date_created=>"09/13/2018", :size=>"818 MB", :url=>"/static/static_db_copies/daily/20180913_clinical_trials.zip"}, {:name=>"20180912_clinical_trials.zip", :date_created=>"09/12/2018", :size=>"817 MB", :url=>"/static/static_db_copies/daily/20180912_clinical_trials.zip"}, {:name=>"20180911_clinical_trials.zip", :date_created=>"09/11/2018", :size=>"818 MB", :url=>"/static/static_db_copies/daily/20180911_clinical_trials.zip"}, {:name=>"20180909_clinical_trials.zip", :date_created=>"09/09/2018", :size=>"818 MB", :url=>"/static/static_db_copies/daily/20180909_clinical_trials.zip"}, {:name=>"20180908_clinical_trials.zip", :date_created=>"09/08/2018", :size=>"817 MB", :url=>"/static/static_db_copies/daily/20180908_clinical_trials.zip"}, {:name=>"20180907_clinical_trials.zip", :date_created=>"09/07/2018", :size=>"817 MB", :url=>"/static/static_db_copies/daily/20180907_clinical_trials.zip"}, {:name=>"20180906_clinical_trials.zip", :date_created=>"09/06/2018", :size=>"816 MB", :url=>"/static/static_db_copies/daily/20180906_clinical_trials.zip"}, {:name=>"20180905_clinical_trials.zip", :date_created=>"09/05/2018", :size=>"815 MB", :url=>"/static/static_db_copies/daily/20180905_clinical_trials.zip"}, {:name=>"20180902_clinical_trials.zip", :date_created=>"09/02/2018", :size=>"815 MB", :url=>"/static/static_db_copies/daily/20180902_clinical_trials.zip"}]
Downloadable File Date Created Size
20180922_clinical_trials.zip 09/22/2018 823 MB
20180921_clinical_trials.zip 09/21/2018 822 MB
20180920_clinical_trials.zip 09/20/2018 822 MB
20180919_clinical_trials.zip 09/19/2018 821 MB
20180918_clinical_trials.zip 09/18/2018 820 MB
20180916_clinical_trials.zip 09/16/2018 820 MB
20180915_clinical_trials.zip 09/15/2018 819 MB
20180914_clinical_trials.zip 09/14/2018 819 MB
20180913_clinical_trials.zip 09/13/2018 818 MB
20180912_clinical_trials.zip 09/12/2018 817 MB
20180911_clinical_trials.zip 09/11/2018 818 MB
20180909_clinical_trials.zip 09/09/2018 818 MB
20180908_clinical_trials.zip 09/08/2018 817 MB
20180907_clinical_trials.zip 09/07/2018 817 MB
20180906_clinical_trials.zip 09/06/2018 816 MB
20180905_clinical_trials.zip 09/05/2018 815 MB
20180902_clinical_trials.zip 09/02/2018 815 MB

Monthly Archive of Static Copies

[{:name=>"20180901_clinical_trials.zip", :date_created=>"09/01/2018", :size=>"813 MB", :url=>"/static/static_db_copies/monthly/20180901_clinical_trials.zip"}, {:name=>"20180801_clinical_trials.zip", :date_created=>"08/01/2018", :size=>"800 MB", :url=>"/static/static_db_copies/monthly/20180801_clinical_trials.zip"}, {:name=>"20180701_clinical_trials.zip", :date_created=>"07/01/2018", :size=>"791 MB", :url=>"/static/static_db_copies/monthly/20180701_clinical_trials.zip"}, {:name=>"20180601_clinical_trials.zip", :date_created=>"06/01/2018", :size=>"780 MB", :url=>"/static/static_db_copies/monthly/20180601_clinical_trials.zip"}, {:name=>"20180501_clinical_trials.zip", :date_created=>"05/01/2018", :size=>"773 MB", :url=>"/static/static_db_copies/monthly/20180501_clinical_trials.zip"}, {:name=>"20180401_clinical_trials.zip", :date_created=>"04/01/2018", :size=>"765 MB", :url=>"/static/static_db_copies/monthly/20180401_clinical_trials.zip"}, {:name=>"20180301_clinical_trials.zip", :date_created=>"03/01/2018", :size=>"755 MB", :url=>"/static/static_db_copies/monthly/20180301_clinical_trials.zip"}, {:name=>"20180201_clinical_trials.zip", :date_created=>"02/01/2018", :size=>"746 MB", :url=>"/static/static_db_copies/monthly/20180201_clinical_trials.zip"}, {:name=>"20180111_clinical_trials.zip", :date_created=>"01/11/2018", :size=>"744 MB", :url=>"/static/static_db_copies/monthly/20180111_clinical_trials.zip"}, {:name=>"20171217_clinical_trials.zip", :date_created=>"12/17/2017", :size=>"737 MB", :url=>"/static/static_db_copies/monthly/20171217_clinical_trials.zip"}, {:name=>"20171102_clinical_trials.zip", :date_created=>"11/02/2017", :size=>"721 MB", :url=>"/static/static_db_copies/monthly/20171102_clinical_trials.zip"}, {:name=>"20171016_clinical_trials.zip", :date_created=>"10/16/2017", :size=>"717 MB", :url=>"/static/static_db_copies/monthly/20171016_clinical_trials.zip"}, {:name=>"20170906_clinical_trials.zip", :date_created=>"09/06/2017", :size=>"701 MB", :url=>"/static/static_db_copies/monthly/20170906_clinical_trials.zip"}, {:name=>"20170811_clinical_trials.zip", :date_created=>"08/11/2017", :size=>"684 MB", :url=>"/static/static_db_copies/monthly/20170811_clinical_trials.zip"}, {:name=>"20170703_clinical_trials.zip", :date_created=>"07/03/2017", :size=>"671 MB", :url=>"/static/static_db_copies/monthly/20170703_clinical_trials.zip"}, {:name=>"20170613_clinical_trials.zip", :date_created=>"06/13/2017", :size=>"661 MB", :url=>"/static/static_db_copies/monthly/20170613_clinical_trials.zip"}, {:name=>"20170502_clinical_trials.zip", :date_created=>"05/02/2017", :size=>"649 MB", :url=>"/static/static_db_copies/monthly/20170502_clinical_trials.zip"}, {:name=>"20170403_clinical_trials.zip", :date_created=>"04/03/2017", :size=>"632 MB", :url=>"/static/static_db_copies/monthly/20170403_clinical_trials.zip"}, {:name=>"20170309_clinical_trials.zip", :date_created=>"03/09/2017", :size=>"628 MB", :url=>"/static/static_db_copies/monthly/20170309_clinical_trials.zip"}, {:name=>"20170218_clinical_trials.zip", :date_created=>"02/18/2017", :size=>"625 MB", :url=>"/static/static_db_copies/monthly/20170218_clinical_trials.zip"}, {:name=>"20170105_clinical_trials.zip", :date_created=>"01/05/2017", :size=>"610 MB", :url=>"/static/static_db_copies/monthly/20170105_clinical_trials.zip"}]
Downloadable File Date Created Size
20180901_clinical_trials.zip 09/01/2018 813 MB
20180801_clinical_trials.zip 08/01/2018 800 MB
20180701_clinical_trials.zip 07/01/2018 791 MB
20180601_clinical_trials.zip 06/01/2018 780 MB
20180501_clinical_trials.zip 05/01/2018 773 MB
20180401_clinical_trials.zip 04/01/2018 765 MB
20180301_clinical_trials.zip 03/01/2018 755 MB
20180201_clinical_trials.zip 02/01/2018 746 MB
20180111_clinical_trials.zip 01/11/2018 744 MB
20171217_clinical_trials.zip 12/17/2017 737 MB
20171102_clinical_trials.zip 11/02/2017 721 MB
20171016_clinical_trials.zip 10/16/2017 717 MB
20170906_clinical_trials.zip 09/06/2017 701 MB
20170811_clinical_trials.zip 08/11/2017 684 MB
20170703_clinical_trials.zip 07/03/2017 671 MB
20170613_clinical_trials.zip 06/13/2017 661 MB
20170502_clinical_trials.zip 05/02/2017 649 MB
20170403_clinical_trials.zip 04/03/2017 632 MB
20170309_clinical_trials.zip 03/09/2017 628 MB
20170218_clinical_trials.zip 02/18/2017 625 MB
20170105_clinical_trials.zip 01/05/2017 610 MB

3

Populate Local PostgreSQL Database from the Static Copy

Once PostgreSQL is installed on your local machine and you have downloaded a static copy of the AACT database, you can create and populate your own database. You have two alternatives for installing it: 1) via a terminal session using command lines or 2) via a graphical user interface (GUI) such as pgAdmin. The command line option is somewhat simpler, so we've highlighted instructions for this below and provided guidance for using the GUI here.

Database Creation Via Command Line

Open a terminal session
  • On a Mac: press [Command] [Spacebar] and enter 'Terminal' in the 'Spotlight Search' dialog that pops up.
  • On a PC: press [Start] and enter 'CMD' in the command input box.

This should open a terminal session where you can enter the following commands.

Initialize empty postgres database: aact

After postgres is installed on your local machine, enter the following command to initialize the AACT database. (You might get the error message 'already exists' if the database was already created; no harm done.)

        

-> createdb aact createdb: database creation failed: ERROR: database "aact" already exists

Locate and unzip the database package/zipfile

Verify the location of the database package you downloaded in step 2 - both the path and the file name. You'll need to unzip this package and use the data dump file it contains to create and populate your own, local instance of the database.

  • On a Mac: The zip package is probably here: ~/Downloads/YYYYMMDD_clinical_trials.zip (where YYYYMMDD is the date the database was copied).

        

-> unzip ~/Downloads/YYYYMMDD_clinical_trials.zip

This will unpack the files contained in the zip package and save them to the directory where the zip file exists. These files include:

  • schema_diagram.png - Database schema diagram that illustrates the relationships between tables.
  • postgres_data.dmp - Postgres dump file containing all the instructions and data required to create a local copy of the AACT database.
  • data_dictionary.xlsx - Spreadsheet that describes all tables and columns in the AACT database.
  • nlm_protocol_definitions.html - Copy of the National Library of Medicine: ClinicalTrials.gov protocol-related documentation.
  • nlm_result_definitions.html - Copy of the National Library of Medicine: ClinicalTrials.gov results-related documentation.
Create and populate your local database instance

Enter the following command to create all database tables in aact and populate them with clinical trials data.

This typically takes 10-20 minutes, depending on the speed of your machine.

        

-> pg_restore -e -v -O -x --dbname=aact --no-owner --clean --create ~/Downloads/postgres_data.dmp

Verify the database

Confirm the download was successful by logging into the database and perusing the data.

  

-> psql aact psql (9.6.1) Type "help" for help. aact=# _

The aact=# prompt indicates that you're in a pSQL console session and can enter SQL commands. AACT tables are saved in a schema named ctgov. You need to add this schema to your pSQL search path:

  

aact=# alter role your-username in database aact set search_path = ctgov, public; ALTER ROLE aact=# _

You will need to logout of psql (with command \q) and then back in for the search path to take effect. Then you can query the database. For example, to find the number of studies in the database:

  

aact=# select count(*) from studies; count -------- 285020 (1 row) aact=# _

PostgreSQL provides helpful instructions on their website. For Windows, the certified Interactive Installer by EnterpriseDB is a good option. It includes a graphical interface for PostgreSQL (pgAdmin). The following instructions are for Postgres Version 9.5.4, pgAdmin III, and SQL Shell (psql).

Using pgAdmin III

  • Connect to the local Postgres server.
  • Using pgAdmin, select a Server, right-click and select Connect, and enter the password to connect to the Postgres server. (The PostgresSQL selection no longer contains a red X.)
  • Create an empty Postgres database and create/populate it from the static copy of AACT.
  • Using pgAdmin, select Databases, right-click and select New Database.
    • Under the Properties tab, enter a name for the Database and click OK
    • Select the new Database, right-click and select Restore
    • In the File Options section, select the name of the AACT database package as the Filename and select postgres as the Rolename
    • In the Restore Options #1 section, under the Don’t save header, select Owner and Privilege and click Restore.

The restore is complete when the Restore database window shows “Process returned exit code 0.”

Execute a sample query Using pgAdmin, select the Database and select SQL from the top menu.

In the SQL window, type...

          

select count(*) from studies

Click the right-arrow in the top menu to execute the sql. The result shows in the results window.

Using psql

  • Connect to the local Postgres server.
  • Using psql, click Enter to confirm:
  • Server [localhost] : (Press [Enter]}
  • Database [postgres] :
  • Port [5432] : (Press [Enter])
  • Username [postgres] : aact
  • Enter the password you created for Password for user postgres:
  • psql (9.5.4)
  • Type "help" for help.
  • postgres=#

We are compiling a list of commonly encountered problems...

Error Possible Resolution

"pg_restore: [archiver (db)] could not execute query: ERROR: unrecognized configuration parameter "row_security"

Upgrade your version of PostgreSQL to 9.6.6.

pg_restore: connecting to database for restore

pg_restore: creating DATABASE "aact"

pg_restore: [archiver (db)] Error while PROCESSING TOC:

pg_restore: [archiver (db)] Error from TOC entry 3543; 1262 1525913 DATABASE aact dbadmin

pg_restore: [archiver (db)] could not execute query: ERROR: database "aact" already exists

Make sure to include --clean in the command to drop the table before creating it.