关于flask-sqlacodegen使用方法的报错
来源:7-2 登陆退出准备工作,数据库GUI工具演示
纪文
2020-03-14
D:\QinMan\order>flask-sqlacodegen “mysql://root:123456@127.0.0.1/food_db?charse
t=utf8mb4” --tables user --outfile “common/models/User.py” --flask
Traceback (most recent call last):
File “f:\python\lib\runpy.py”, line 170, in run_module_as_main
"main", mod_spec)
File “f:\python\lib\runpy.py”, line 85, in run_code
exec(code, run_globals)
File "F:\python\Scripts\flask-sqlacodegen.exe_main.py", line 7, in
File “f:\python\lib\site-packages\sqlacodegen\main.py”, line 56, in main
metadata.reflect(engine, args.schema, not args.noviews, tables)
File “f:\python\lib\site-packages\sqlalchemy\sql\schema.py”, line 4208, in re
flect
with bind.connect() as conn:
File “f:\python\lib\site-packages\sqlalchemy\engine\base.py”, line 2209, in c
onnect
return self.connection_cls(self, **kwargs)
File “f:\python\lib\site-packages\sqlalchemy\engine\base.py”, line 103, in __
init
else engine.raw_connection()
File “f:\python\lib\site-packages\sqlalchemy\engine\base.py”, line 2307, in r
aw_connection
self.pool.unique_connection, _connection
File “f:\python\lib\site-packages\sqlalchemy\engine\base.py”, line 2276, in _
wrap_pool_connect
return fn()
File “f:\python\lib\site-packages\sqlalchemy\pool\base.py”, line 303, in uniq
ue_connection
return _ConnectionFairy._checkout(self)
File “f:\python\lib\site-packages\sqlalchemy\pool\base.py”, line 773, in _che
ckout
fairy = _ConnectionRecord.checkout(pool)
File “f:\python\lib\site-packages\sqlalchemy\pool\base.py”, line 492, in chec
kout
rec = pool._do_get()
File “f:\python\lib\site-packages\sqlalchemy\pool\impl.py”, line 139, in do
get
self._dec_overflow()
File “f:\python\lib\site-packages\sqlalchemy\util\langhelpers.py”, line 68, i
n exit
compat.reraise(exc_type, exc_value, exc_tb)
File “f:\python\lib\site-packages\sqlalchemy\util\compat.py”, line 153, in re
raise
raise value
File “f:\python\lib\site-packages\sqlalchemy\pool\impl.py”, line 136, in do
get
return self._create_connection()
File “f:\python\lib\site-packages\sqlalchemy\pool\base.py”, line 308, in _cre
ate_connection
return _ConnectionRecord(self)
File “f:\python\lib\site-packages\sqlalchemy\pool\base.py”, line 437, in in
it
self.__connect(first_connect_check=True)
File “f:\python\lib\site-packages\sqlalchemy\pool\base.py”, line 652, in __co
nnect
connection = pool.invoke_creator(self)
File “f:\python\lib\site-packages\sqlalchemy\engine\strategies.py”, line 114,
in connect
return dialect.connect(*cargs, **cparams)
File “f:\python\lib\site-packages\sqlalchemy\engine\default.py”, line 489, in
connect
return self.dbapi.connect(*cargs, **cparams)
File "f:\python\lib\site-packages\MySQLdb_init.py", line 86, in Connect
return Connection(*args, **kwargs)
File “f:\python\lib\site-packages\MySQLdb\connections.py”, line 204, in ini
t
super(Connection, self).init(*args, **kwargs2)
TypeError: ‘User’ is an invalid keyword argument for this function
10回答
-
编程浪子
2020-03-14
你好
看我的回复呀
10 -
编程浪子
2020-03-15
你好
其实手动生成也可以,你这样,直接去源码把model 复制起来用,等做完了在来看看这什么问题,这样时间充裕
00 -
编程浪子
2020-03-15
你好
你把models下面的__init__.py 删除了在重新执行命令看看
012020-03-15 -
纪文
提问者
2020-03-15
这个文件里面
00 -
纪文
提问者
2020-03-15
是不是这里出问题了
022020-03-15 -
纪文
提问者
2020-03-14
还是这个问题,好奇怪
D:\QinMan\order>flask-sqlacodegen "mysql://root:123456@127.0.0.1/food_db?charset
=utf8mb4" --tables abcd --outfile "common/models/abcd.py" --flask
Traceback (most recent call last):
File "f:\python\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "f:\python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "F:\python\Scripts\flask-sqlacodegen.exe\__main__.py", line 7, in <module
>
File "f:\python\lib\site-packages\sqlacodegen\main.py", line 56, in main
metadata.reflect(engine, args.schema, not args.noviews, tables)
File "f:\python\lib\site-packages\sqlalchemy\sql\schema.py", line 4208, in ref
lect
with bind.connect() as conn:
File "f:\python\lib\site-packages\sqlalchemy\engine\base.py", line 2209, in co
nnect
return self._connection_cls(self, **kwargs)
File "f:\python\lib\site-packages\sqlalchemy\engine\base.py", line 103, in __i
nit__
else engine.raw_connection()
File "f:\python\lib\site-packages\sqlalchemy\engine\base.py", line 2307, in ra
w_connection
self.pool.unique_connection, _connection
File "f:\python\lib\site-packages\sqlalchemy\engine\base.py", line 2276, in _w
rap_pool_connect
return fn()
File "f:\python\lib\site-packages\sqlalchemy\pool\base.py", line 303, in uniqu
e_connection
return _ConnectionFairy._checkout(self)
File "f:\python\lib\site-packages\sqlalchemy\pool\base.py", line 773, in _chec
kout
fairy = _ConnectionRecord.checkout(pool)
File "f:\python\lib\site-packages\sqlalchemy\pool\base.py", line 492, in check
out
rec = pool._do_get()
File "f:\python\lib\site-packages\sqlalchemy\pool\impl.py", line 139, in _do_g
et
self._dec_overflow()
File "f:\python\lib\site-packages\sqlalchemy\util\langhelpers.py", line 68, in
__exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "f:\python\lib\site-packages\sqlalchemy\util\compat.py", line 153, in rer
aise
raise value
File "f:\python\lib\site-packages\sqlalchemy\pool\impl.py", line 136, in _do_g
et
return self._create_connection()
File "f:\python\lib\site-packages\sqlalchemy\pool\base.py", line 308, in _crea
te_connection
return _ConnectionRecord(self)
File "f:\python\lib\site-packages\sqlalchemy\pool\base.py", line 437, in __ini
t__
self.__connect(first_connect_check=True)
File "f:\python\lib\site-packages\sqlalchemy\pool\base.py", line 652, in __con
nect
connection = pool._invoke_creator(self)
File "f:\python\lib\site-packages\sqlalchemy\engine\strategies.py", line 114,
in connect
return dialect.connect(*cargs, **cparams)
File "f:\python\lib\site-packages\sqlalchemy\engine\default.py", line 489, in
connect
return self.dbapi.connect(*cargs, **cparams)
File "f:\python\lib\site-packages\MySQLdb\__init__.py", line 86, in Connect
return Connection(*args, **kwargs)
File "f:\python\lib\site-packages\MySQLdb\connections.py", line 204, in __init
__
super(Connection, self).__init__(*args, **kwargs2)
TypeError: 'User' is an invalid keyword argument for this function
00 -
纪文
提问者
2020-03-14
版本截图
00 -
纪文
提问者
2020-03-14
老师,下面是flask-sqlacodegen的截图
00 -
编程浪子
2020-03-14
你好
很奇怪,麻烦你配合我做一些调试步骤
执行如下命令(然后截图) flask-sqlacodegen 执行如下命令(然后截图) flask-sqlacodegen --version
如上两步是让我判断软件的。我建议你这样操作一下来验证一下
你把 user 改成 abcd,然后执行
flask-sqlacodegen "mysql://root:123456@127.0.0.1/food_db?charset=utf8mb4" --tables abcd --outfile "common/models/abcd.py" --flask
022020-03-14 -
编程浪子
2020-03-14
你好
试试下面的这个
flask-sqlacodegen "mysql://root:123456@127.0.0.1/food_db?charset=utf8mb4" --tables user --outfile "common/models/user.py" --flask
042020-03-14
相似问题