Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

lari4 avatar image
lari4 asked Erick Ramirez edited

How do insert I data into a nested UDT with the Python driver?

Hi... I am sorry. Can someone help me. I have a field in table which is declared as udt - nmap_data frozen<nmap_data_element>. Type nmap_data_element also contains udt field - list<frozen <nmap_hostnames> > How do I write data to this table from python. I declare classes, tried to register through register_user_type, but it still does not work, it gives out "Invalid user type literal for nmap_data: field hostnames is not of type list<frozen<nmap_hostnames>>"

python driveruser-defined type
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered lari4 commented

The error you posted indicates that you've defined a field called hostnames which is not the right type. But it's hard to know what mistake you've made without the schema for the UDTs and the tables.

Also, be aware that I wouldn't recommend using nested UDTs because it makes it more difficult for you to maintain your application. Where possible, try to stick to storing data in columns unless you really need to use UDTs. Cheers!

1 comment Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thank you for your reply. I'll change the scheme.

0 Likes 0 ·