음, 파일을 분석하는 Python 프로그램이 있습니다. 이러한 파일의 데이터는 다음과 같습니다Python과 MySql - 기하학 객체를 얻을 수 없습니다.
Type=0x21
Label=2428
Data1=(54.67346,59.00001),(54.67415,59.00242),(54.67758,59.00001)
이 내 코드, 그것은 MySQL의 데이터베이스
import MySQLdb
f = open('test.mp', 'r')
db = MySQLdb.connect(host="127.0.0.1", user="root", passwd="", db="gis", charset='utf8')
cursor = db.cursor()
i=0
for line in f.readlines():
if (line.startswith("Type")):
type=line[5:]
if (line.startswith("Label")):
label=line[6:]
if (line.startswith("Data")):
data=line[6:]
sql="""INSERT INTO `polylines` (Type, Label, Data) VALUES ('%(Type)s', '%(Label)s', '%(Data)s')"""%{"Type":type, "Label":label, "Data":data}
cursor.execute(sql)
db.commit()
db.close()
f.close()
에 분석 데이터를 전송하고 난 항상 같은 오류 얻을 수있다 -
_mysql_exceptions.OperationalError: (1416, 'Cannot get
geometry object from data you send to the GEOMETRY field')
을
데이터 변수의 데이터를 데이터베이스의 선 스트링 필드로 보내기 때문이라고 생각합니다. 나는 (1, 2, 3, 3)처럼 보일 날을 바꿔 보려고했지만이 오류가 다시 나타납니다. 데이터를 변경하고이 오류를 방지하려면 어떻게해야합니까?