0
votes

I am trying to update data from JIRA to Redshift DB using python. I am having issues updating value from 'description' column. The target column in DB is of type varchar.

Given below is how I modify the 'description' column before inserting it into Redshift DB.

df['description'] = df['description'].astype(str)

And it throws the below error:

DataError: value too long for type character varying(256)

Is there anything wrong that I am doing to have this field inserted. Length of values in the description column go upto 6000 characters.

Any help on this, would be appreciated..

1

1 Answers

0
votes

Probably duplicate of this.

df['description'] = df['description'].str.slice(0,255)

EDIT AFTER COMMENT Here is my fully working example.

import pandas as pd

d = {'name' : pd.Series(['FFFFF', 'FFFFF', 'FFFFFGGGGg'], index=['a', 'b', 'c']),
     'description' : pd.Series(['FFFFF', 'FFFFF', 'FFFFFGGGGg','4666666666'], index=['a', 'b', 'c', 'd']),
     'place' : pd.Series(['166666660', '26666666660', '3666666660'], index=['a', 'b', 'c'])}

df = pd.DataFrame(d)
print ("Our dataframe is:")
print (df)

print ("Modifying column description:")

df['description'] = df['description'].str.slice(0,4)
print(df)