TypeDB 2 question

Sorry for the annoying v2 question, but this is our last release before upgrading. How do i print out the detail inside the map returned from an insert query? Basically, at the moment we do this:
def load_typeql_data(data_list, stix_connection: Dict[str, str]):
url = stix_connection["uri"] + ":" + stix_connection["port"]
with TypeDB.core_driver(url) as driver:
# Stage 1: Load the data
with driver.session(stix_connection["database"], SessionType.DATA) as session:
with session.transaction(TransactionType.WRITE) as write_transaction:
logger.info(f'Loading TQL objects')
for data in data_list:
logger.info(f'\n\n{data}\n\n')
insert_iterator = write_transaction.query.insert(data)

logger.info(f'insert_iterator response ->\n{insert_iterator}')
for result in insert_iterator:
logger.info(f'typedb response ->\n{result}')

write_transaction.commit()
def load_typeql_data(data_list, stix_connection: Dict[str, str]):
url = stix_connection["uri"] + ":" + stix_connection["port"]
with TypeDB.core_driver(url) as driver:
# Stage 1: Load the data
with driver.session(stix_connection["database"], SessionType.DATA) as session:
with session.transaction(TransactionType.WRITE) as write_transaction:
logger.info(f'Loading TQL objects')
for data in data_list:
logger.info(f'\n\n{data}\n\n')
insert_iterator = write_transaction.query.insert(data)

logger.info(f'insert_iterator response ->\n{insert_iterator}')
for result in insert_iterator:
logger.info(f'typedb response ->\n{result}')

write_transaction.commit()
Unfortunately the logged insert_iterator is not at all useful. How do we get more detail on this map? I have an error i cant track down, and its killing me
11:44:02,540 stixorm.module.typedb_lib.queries INFO insert_iterator response ->
<map object at 0x0000025D9A1C9090>
11:44:02,540 stixorm.module.typedb_lib.queries INFO insert_iterator response ->
<map object at 0x0000025D9A1C9090>
9 Replies
Joshua
Joshua2w ago
i think you can convert it to a list? data = list(insert_iterator) i've forgotten the 2.x API a bit give me a sec
modeller
modellerOP2w ago
nice, thanks, I am getting one object not installing,
Joshua
Joshua2w ago
still insert returns an iterator
modeller
modellerOP2w ago
and it just doesnt give a response
Joshua
Joshua2w ago
https://typedb.com/docs/drivers/2.x/python/api-reference#_QueryManager_insert_query_str_options_TypeDBOptions_None if there's no response then check if the match part is returning anything itself first ie just run it in studio or console or soething to validate
modeller
modellerOP2w ago
right, so it may be a mis-ordering, right, of course, good idea, let me check
Joshua
Joshua2w ago
ok good luck im just going to bed!
modeller
modellerOP2w ago
thanks, it must be it realistically cheers that was the answer, hahahaha, i'm sorry for asking such a dumb question
Joshua
Joshua2w ago
amazing

Did you find this page helpful?