how to define long varchar in hazelcast python client?
6273parastu opened this issue · 7 comments
Hi, I create map in hazelcast with sql statement like this:
query = f'''CREATE MAPPING {category_name}(
__key INT,
create_time BIGINT,
raw_database VARCHAR)
TYPE IMap
OPTIONS('keyFormat'='int', 'valueFormat'='json-flat');'''
create_category_response = client.sql.execute(query)
when i insert long varchar in map:
query = f"INSERT INTO {category_name} VALUES(1, 146546321654, '{row_database}');"
reponse = client.sql.execute(query)
get error like this:
HazelcastSqlError("Length of identifier 'jkhbjhbkjqwertyuiop[]asdfghjkl;'/.mnbvcxzasdfgqewrtyhygjutjqazwsxedcrfvtgbnhytgujmnhy15978huinhtrfvgdeswapkmjbgjnbhytqwexzasfeaqijnhb531254872gtdghgggggga", ' must be less than or equal to 128 characters", None)
@6273parastu Is the category_name
equal to jkhbjhbkjqwertyuiop[]asdfghjkl;'/.mnbvcxzasdfgqewrtyhygjutjqazwsxedcrfvtgbnhytgujmnhy15978huinhtrfvgdeswapkmjbgjnbhytqwexzasfeaqijnhb531254872gtdghgggggga",
?
No, row_database
equal to jkhbjhbkjqwertyuiop[]asdfghjkl;'/.mnbvcxzasdfgqewrtyhygjutjqazwsxedcrfvtgbnhytgujmnhy15978huinhtrfvgdeswapkmjbgjnbhytqwexzasfeaqijnhb531254872gtdghgggggga",
@6273parastu I see. You need to escape the single quote in your row_database
. You can do that by using double single quotes. So,
jkhbjhbkjqwertyuiop[]asdfghjkl;'/.mnbvcxzasdfgqewrtyhygjutjqazwsxedcrfvtgbnhytgujmnhy15978huinhtrfvgdeswapkmjbgjnbhytqwexzasfeaqijnhb531254872gtdghgggggga",
should become
jkhbjhbkjqwertyuiop[]asdfghjkl;''/.mnbvcxzasdfgqewrtyhygjutjqazwsxedcrfvtgbnhytgujmnhy15978huinhtrfvgdeswapkmjbgjnbhytqwexzasfeaqijnhb531254872gtdghgggggga",
raw_database = 'YsSDYs9in24zYqiDYqNmE24zYqiDZgdix2YjYtNuMINmB24zZhtin2YQg2KzYp9mFINit2LDZgduMCgrwn5S52KjZhNuM2Kog2YHYsdmI2LTbjCDYqNin2LLbjCDZgduM2YbYp9mEINis2KfZhSDYrdiw2YHbjCDYqNuM2YYg2K'
query = f"INSERT INTO {category_name} VALUES(1, 146546321654, {raw_database});"
reponse = client.sql.execute(query)
i get this error:
HazelcastSqlError("Length of identifier 'YsSDYs9in24zYqiDYqNmE24zYqiDZgdix2YjYtNuMINmB24zZhtin2YQg2KzYp9mFINit2LDZgduMCgrwn5S52KjZhNuM2Kog2YHYsdmI2LTbjCDYqNin2LLbjCDZgduM2YbYp9mEINis2KfZhSDYrdiw2YHbjCDYqNuM2YYg2K' must be less than or equal to 128 characters", None)
@6273parastu put your raw_database
variable in between single quotes:
query = f"INSERT INTO {category_name} VALUES(1, 146546321654, '{raw_database}');"
fix it 👍
Teşekkür ederim – Thank You
No problem at all. I am closing this issue then.