PYTHON/Error Data

MySQL 오류 : sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1170, "BLOB/TEXT column

  • -

오류 코드

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1170, "BLOB/TEXT column 'XXXX' used in key specification without a key length")

 

해결 방법

인덱스 설정에 있어서 발생하는 오류에 해당함. 따라서 to_sql 내부에 있는 index=True와 그 전의 set_index()가 중복되지 않도록 변경하면 됨

  • ① set_index()를 지운 후 to_sql 내에서 index=True를 사용
  • ② set_index()를 유지 후 to_sql 내에서 index=False를 사용
## 수정 전
tempt_data = pd.DataFrame(self.ohlcv, columns=['dtime', 'date', 'time', 'open', 'high', 'low', 'close', 'volume', 'tvolume'])
send_data = tempt_data.set_index('date', 'time')
send_data.to_sql(name="s" + code, con=engine_15min, index=True, if_exists='replace')

## 수정 후
tempt_data = pd.DataFrame(self.ohlcv, columns=['dtime', 'date', 'time', 'open', 'high', 'low', 'close', 'volume', 'tvolume'])
tempt_data.to_sql(name="s" + code, con=engine_15min, index=True, if_exists='replace')

 

 

 


 

728x90
반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.