当我运行PWIZ从现有的数据库生成PeeEE调制解调器时,它显示出以下错误:

root@server:~# python -m pwiz -e mysql  -P  -H 127.0.0.1 mysql
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/pwiz.py", line 202, in <module>
    print_models(introspector, tables, preserve_order=options.preserve_order)
  File "/usr/local/lib/python2.7/dist-packages/pwiz.py", line 47, in print_models
    database = introspector.introspect(table_names=tables)
  File "/usr/local/lib/python2.7/dist-packages/playhouse/reflection.py", line 440, in introspect
    tables = self.metadata.database.get_tables()
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3089, in get_tables
    return [table for table, in self.execute_sql('SHOW TABLES')]
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2459, in execute_sql
    cursor = self.cursor(commit)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2445, in cursor
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2411, in connect
    self._state.set_connection(self._connect())
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3083, in _connect
    return mysql.connect(db=self.database, **self.connect_params)
AttributeError: 'NoneType' object has no attribute 'connect'

怎么了?数据库的用户名和密码正确。

最佳答案

PyMySql未安装。使用pip或其他可用选项安装:

pip install PyMySql

不幸的是,peewee没有在依赖项列表中写入python的PyMySql1模块,因此应该单独安装。

关于mysql - 使用pwiz从mysql生成peewee模型时出现AttributeError,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48541194/

10-13 07:47