SQL 错误 [22021]: ERROR: invalid byte sequence for encoding "UTF8": 0xb3 (seg0 slice1 127.0.0.1:6000 pid=3852) 在位置:External table stif, line 1 of file gpfdist://mdw:8081/stif.csv
org.jkiss.dbeaver.model.sql.DBSQLException: SQL 错误 [22021]: ERROR: invalid byte sequence for encoding "UTF8": 0xb3 (seg0 slice1 127.0.0.1:6000 pid=3852) 在位置:External table stif, line 1 of file gpfdist://mdw:8081/stif.csv at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:133) at org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable.readData(JDBCTable.java:190) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:118) at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:171) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:116) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:4821) at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0xb3 (seg0 slice1 127.0.0.1:6000 pid=3852) 在位置:External table stif, line 1 of file gpfdist://mdw:8081/stif.csv at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:322) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:308) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:284) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:279) at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:330) at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:130) ... 7 more
SQL 错误 [22021]: ERROR: invalid byte sequence for encoding “UTF8”: 0xb3 (seg1 slice1 127.0.0.1:6001 pid=4145) 在位置:External table stif, line 1 of file gpfdist://mdw:8081/stif.csv
解决办法1:转换成txt再导入
无法转换成txt,python显示
1 2 3 4 5 6 7 8
Traceback (most recent call last): File "/Users/roy/PycharmProjects/data_transfer/main.py", line 11, in <module> [ File "/Users/roy/PycharmProjects/data_transfer/main.py", line 11, in <listcomp> [ File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 20: invalid start byte
解决办法2:切换encoding
format ‘csv’, delimiter ‘, encoding ‘ISO-8859-1’)” $dbname
SQL 错误 [22021]: ERROR: invalid byte sequence for encoding "UTF8": 0xc8 0xfd (seg1 slice1 127.0.0.1:6001 pid=5441) 在位置:External table relation, line 1 of file gpfdist://mdw:8081/relation.csv
org.jkiss.dbeaver.model.sql.DBSQLException: SQL 错误 [22021]: ERROR: invalid byte sequence for encoding "UTF8": 0xc8 0xfd (seg1 slice1 127.0.0.1:6001 pid=5441) 在位置:External table relation, line 1 of file gpfdist://mdw:8081/relation.csv at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:133) at org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable.readData(JDBCTable.java:190) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:118) at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:171) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:116) at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:4821) at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0xc8 0xfd (seg1 slice1 127.0.0.1:6001 pid=5441) 在位置:External table relation, line 1 of file gpfdist://mdw:8081/relation.csv at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:322) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:308) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:284) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:279) at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:330) at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:130) ... 7 more
The authenticity of host '[agilec.gicp.net]:50009 ([222.128.178.75]:50009)' can't be established. ECDSA key fingerprint is SHA256:xOPh2JzO597wKLvgc7q73C4AYjzCeYBZR7hTuNk+uT4. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '[agilec.gicp.net]:50009,[222.128.178.75]:50009' (ECDSA) to the list of known hosts. admin@agilec.gicp.net's password:
Last login: Tue May 17 00:31:42 2022 from 119.166.234.126
sed -i "s/&#@/,/g" stif_2022-03-12.csv sed -i "s/&#@/,/g" address_2022-03-12.csv sed -i "s/&#@/,/g" bact_2022-03-12.csv sed -i "s/&#@/,/g" cert_2022-03-12.csv sed -i "s/&#@/,/g" org_2022-03-12.csv sed -i "s/&#@/,/g" pact_2022-03-12.csv sed -i "s/&#@/,/g" person_2022-03-12.csv sed -i "s/&#@/,/g" relation_2022-03-12.csv sed -i "s/&#@/,/g" tel_2022-03-12.csv
sed -i "s/&#@/,/g" stif_2022-03-19.csv sed -i "s/&#@/,/g" stif_2022-03-20.csv sed -i "s/&#@/,/g" stif_2022-03-21.csv
time psql gpdb -c "INSERT INTO stif (select * from ext_stif)"; time psql gpdb -c "INSERT INTO address (select * from ext_address)"; time psql gpdb -c "INSERT INTO bact (select * from ext_bact)"; time psql gpdb -c "INSERT INTO cert (select * from ext_cert)"; time psql gpdb -c "INSERT INTO org (select * from ext_org)"; time psql gpdb -c "INSERT INTO pact (select * from ext_pact)"; time psql gpdb -c "INSERT INTO person (select * from ext_person)"; time psql gpdb -c "INSERT INTO relation (select * from ext_relation)"; time psql gpdb -c "INSERT INTO tel (select * from ext_tel)";