同样的命令,偶尔出现入库失败
shuixianer opened this issue · 2 comments
如题,偶尔就出现下面的错误:
F:\Python\test_data>datafaker rdb mysql+mysqldb://root:@localhost:3306/datafaker?charset=utf8 stu 10 --meta meta.txt --batch 1 --workers 2
insert 1 records
insert 2 records
insert 3 records
insert 4 records
insert 5 records
insert 6 records
insert 7 records
insert 8 records
insert 9 records
insert 10 records
Exception in thread Thread-2:
Traceback (most recent call last):
File "F:\Python\Python-2.7.16\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "F:\Python\Python-2.7.16\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "build\bdist.win-amd64\egg\datafaker\dbs\basedb.py", line 122, in save
self.save_data(lines)
File "build\bdist.win-amd64\egg\datafaker\dbs\rdbdb.py", line 26, in save_data
self.save_other_rdb(lines, names_format, column_names)
File "build\bdist.win-amd64\egg\datafaker\dbs\rdbdb.py", line 42, in save_other_rdb
self.session.execute(sql)
File "build\bdist.win-amd64\egg\sqlalchemy\orm\session.py", line 1269, in execute
clause, params or {}
File "build\bdist.win-amd64\egg\sqlalchemy\engine\base.py", line 988, in execute
return meth(self, multiparams, params)
File "build\bdist.win-amd64\egg\sqlalchemy\sql\elements.py", line 287, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "build\bdist.win-amd64\egg\sqlalchemy\engine\base.py", line 1107, in _execute_clauseelement
distilled_params,
File "build\bdist.win-amd64\egg\sqlalchemy\engine\base.py", line 1253, in _execute_context
e, statement, parameters, cursor, context
File "build\bdist.win-amd64\egg\sqlalchemy\engine\base.py", line 1473, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "build\bdist.win-amd64\egg\sqlalchemy\util\compat.py", line 398, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "build\bdist.win-amd64\egg\sqlalchemy\engine\base.py", line 1249, in _execute_context
cursor, statement, parameters, context
File "build\bdist.win-amd64\egg\sqlalchemy\engine\default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "F:\Python\Python-2.7.16\lib\site-packages\MySQLdb\cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "F:\Python\Python-2.7.16\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (_mysql_exceptions.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL s
erver version for the right syntax to use near '' at line 1")
[SQL: insert into stu (name,school,nickname,age,class_num,score,phone,email,ip,address) values ]
(Background on this error at: http://sqlalche.me/e/f405)
time used: 4.324 s
日志上判断不出问题
看最底下一行,看起来像是线程安全的问题 [SQL: insert into stu (name,school,nickname,age,class_num,score,phone,email,ip,address) values ]