PyCharm 2023.3 Help

Apache Cassandra with SSL

Enable the Database Tools and SQL plugin

This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in PyCharm by default. If the relevant features aren't available, make sure that you didn't disable the plugin.

  1. Press Ctrl+Alt+S to open the IDE settings and then select Plugins.

  2. Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.

Step 1. Create a Apache Cassandra connection

  1. To connect to the database, create a data source that will store your connection details. You can do this using one of the following ways:

    • In the main menu, go to File | New | Data Source and select Apache Cassandra.

    • In the Database tool window ( View | Tool Windows | Database) , click the New icon (the New icon) in the toolbar. Navigate to Data Source and select Apache Cassandra.

    Create a new data source
  2. Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.

    Location for the downloaded JDBC drivers is the PyCharm configuration directory.

    The Download missing driver files link

    You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, refer to Add a user driver to an existing connection.

    If there is no Download missing driver files link, then you already have the required drivers.

  3. In Host, Keyspace, User, Password, and Port fields, specify connection details.

Step 2. Verify the version of the JDBC driver

Verify that you use the JDBC driver of version 1.3, or later.

  1. Open data source properties. You can open data source properties by using one of the following options:

    • In the Database tool window ( View | Tool Windows | Database) , click the Data Source Properties icon The Data Source Properties icon.

    • Press Shift+Enter.

  2. In the Drivers tab, select Apache Cassandra.

  3. In the Driver files pane, click ver. <version_number> and select Latest or 1.3.

Verify the version of the JDBC driver

Step 3. Set VM options

  1. Open data source properties. You can open data source properties by using one of the following options:

    • In the Database tool window ( View | Tool Windows | Database) , click the Data Source Properties icon The Data Source Properties icon.

    • Press Shift+Enter.

  2. In the Drivers tab, select Apache Cassandra.

  3. In the driver settings, click the Advanced tab.

  4. In the VM options field, specify options for authentication.

    • Server authentication: your client verifies that the server is correct and trusted. The truststore must contain a public key of the server or the CA certificate that was used to sign the server key.

      -Djavax.net.ssl.trustStore=<path_to_client_truststore> -Djavax.net.ssl.trustStorePassword=<truststore_password>
    • Client authentication: the server verifies the client that tries to connect to the server.

      -Djavax.net.ssl.keyStore=<path_to_client_keystore> -Djavax.net.ssl.keyStorePassword=<keystore_password>
Set VM options

Step 4. Add the sslenabled option to the JDBC URL

  1. Add the sslenabled=true option to the JDBC URL. For example, jdbc:cassandra://localhost:9042/?sslenabled=true.

  2. Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.

    Test Connection link

    In case of any connection issues, refer to the Cannot connect to a database page.

  3. (Optional) By default, only the default keyspace is introspected and available to work with. If you also want to work with other keyspaces, in the Schemas tab, select them for the introspection.

    Schemas tab of the Data Sources and Drivers dialog
  4. Click OK to create the data source.

  5. Find your new data source in the Database tool window (⌘ 1) .

    • For more information about the Database tool window, see the corresponding reference topic.

    • For more information about working with database objects in PyCharm, refer to Database objects.

    • To write and run queries, open the default query console by clicking the data source and pressing F4.

    • To view and edit data of a database object, open Data editor and viewer by double-clicking the object.

Add the sslenabled option to the JDBC URL
Last modified: 11 February 2024