Build a PostgreSQL Interface for Claude Compliance Data using the CData JDBC Driver

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Use the Remoting features of the Claude Compliance JDBC Driver to create a PostgreSQL entry-point for data access.

There are a vast number of PostgreSQL clients available on the Internet. From standard Drivers to BI and Analytics tools, PostgreSQL is a popular interface for data access. Using our JDBC Drivers, you can now create PostgreSQL entry-points that you can connect to from any standard client.

To access Claude Compliance data as a PostgreSQL database, use the CData JDBC Driver for Claude Compliance and a JDBC foreign data wrapper (FDW). In this article, we compile the FDW, install it, and query Claude Compliance data from PostgreSQL Server.

Connect to Claude Compliance Data as a JDBC Data Source

To connect to Claude Compliance as a JDBC data source, you will need the following:

  • Driver JAR path: The JAR is located in the lib subfolder of the installation directory.
  • Driver class:

    
    cdata.jdbc.claudecompliance.ClaudeComplianceDriver
    

  • JDBC URL: The URL must start with "jdbc:claudecompliance:" and can include any of the connection properties in name-value pairs separated with semicolons.

    The driver connects to Claude Compliance using a Compliance Access Key, the only supported authentication method. Set the following connection property:

    • APIKey: The Compliance Access Key you created.

    Creating a Compliance Access Key

    1. Enable the Compliance API for your organization.
    2. Sign in to claude.ai as a primary owner or organization owner and open Organization settings > API > Keys.
    3. Select Create Key and assign only the scopes your integration needs:
      • read:compliance_activities for Activities and the typed activity views.
      • read:compliance_org_data for organizations, roles, groups, and settings.
      • read:compliance_user_data for users, chats, files, projects, and downloads.
      • delete:compliance_user_data for the explicit Delete stored procedures.
    4. Create the key and copy it when it appears. The key starts with sk-ant-api01- and is shown only once.

    Optionally, set OrganizationUUID to limit organization-scoped views (such as OrganizationUsers and ComplianceRoles) to a single linked organization. If it is left empty, those views default to the first available organization and do not include data from all linked organizations.

    Built-in Connection String Designer

    For assistance in constructing the JDBC URL, use the connection string designer built into the Claude Compliance JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

    
    java -jar cdata.jdbc.claudecompliance.jar
    

    Fill in the connection properties and copy the connection string to the clipboard.

    Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)

    A typical JDBC URL is below:

    
    jdbc:claudecompliance:APIKey=your_compliance_access_key;
    

Build the JDBC Foreign Data Wrapper

The Foreign Data Wrapper can be installed as an extension to PostgreSQL, without recompiling PostgreSQL. The jdbc2_fdw extension is used as an example (downloadable here).

  1. Add a symlink from the shared object for your version of the JRE to /usr/lib/libjvm.so. For example:
    
    ln -s /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so /usr/lib/libjvm.so
    
  2. Start the build:
    
    make install USE_PGXS=1
    

Query Claude Compliance Data as a PostgreSQL Database

After you have installed the extension, follow the steps below to start executing queries to Claude Compliance data:

  1. Log into your database.
  2. Load the extension for the database:
    
    CREATE EXTENSION jdbc2_fdw;
    
  3. Create a server object for Claude Compliance:
    
    CREATE SERVER ClaudeCompliance 
    FOREIGN DATA WRAPPER jdbc2_fdw OPTIONS (
    drivername 'cdata.jdbc.claudecompliance.ClaudeComplianceDriver',
    url 'jdbc:claudecompliance:APIKey=your_compliance_access_key;',
    querytimeout '15',
    jarfile '/home/MyUser/CData/CData\ JDBC\ Driver\ for\ Salesforce MyDriverEdition/lib/cdata.jdbc.claudecompliance.jar'); 
    
  4. Create a user mapping for the username and password of a user known to the MySQL daemon.
    
    CREATE USER MAPPING for postgres SERVER ClaudeCompliance OPTIONS (
    username 'admin', 
    password 'test');
    
  5. Create a foreign table in your local database:
    
    postgres=# CREATE FOREIGN TABLE projects (
    projects_id text,
    projects_Id text,
    projects_Name numeric) 
    SERVER ClaudeCompliance OPTIONS (
    table_name 'projects');
    
You can now execute SELECT commands to Claude Compliance:

postgres=# SELECT * FROM projects;

Ready to get started?

Download a free trial of the Claude Compliance Driver to get started:

 Download Now

Learn more:

Claude Compliance Icon Claude Compliance JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Claude Compliance data including Activities, Chats, ChatMessages, CodeArtifacts, ComplianceRoles, Organizations, OrganizationUsers, Projects, and more!