CData Python Connector for Cassandra

Build 24.0.9060

UseJsonFormat

Whether to submit and return the JSON encoding for CQL data types.

Data Type

bool

Default Value

true

Remarks

Cassandra 2.2 introduced a CQL extension that allows you to JSON-encode CQL data types. By default, you use the JSON syntax to manipulate data and SELECT statements return JSON through the connector. Set this property to false to use CQL literals to interact with Cassandra data.

The syntax for CQL literals has several differences from JSON. For example:

  • CQL strings are defined in single quotes, while JSON strings are defined in double quotes.
  • CQL sets, tuples, and lists are JSON-encoded as arrays.
  • User-defined types and CQL uuid types are JSON-encoded as objects.
Refer to the CQL documentation for more information on how to JSON-encode data types in your version of Cassandra. Below is an example SQL statement using JSON and CQL.

FormatSyntax
CQL
INSERT INTO users (user_id, emails) VALUES (@user_id, @emails)
Parameters
user_idfrodo
emails{'[email protected]', '[email protected]'}
JSON
INSERT INTO users (user_id, emails) VALUES (@user_id, @emails)
Parameters
user_idfrodo
emails["[email protected]", "[email protected]"])

Note that in queries to the connector, you must use single quotes to define strings.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060