mysql1050错误:表已经存在

news/2024/11/8 16:44:09/

今天做练习,创建库,修改表的时候,一直报表已经存在的错误

pymysql.err.InternalError: (1050, "Table 'usermodel' already exists")The above exception was the direct cause of the following exception:Traceback (most recent call last):File "manage.py", line 20, in <module>manager.run()File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\flask_script\__init__.py", line 417, in runresult = self.handle(argv[0], argv[1:])File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\flask_script\__init__.py", line 386, in handleres = handle(*args, **config)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\flask_script\commands.py", line 216, in __call__return self.run(*args, **kwargs)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\flask_migrate\__init__.py", line 96, in wrappedf(*args, **kwargs)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\flask_migrate\__init__.py", line 271, in upgradecommand.upgrade(config, revision, sql=sql, tag=tag)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\command.py", line 298, in upgradescript.run_env()File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\script\base.py", line 489, in run_envutil.load_python_file(self.dir, "env.py")File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\util\pyfiles.py", line 98, in load_python_filemodule = load_module_py(module_id, path)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\util\compat.py", line 184, in load_module_pyspec.loader.exec_module(module)File "<frozen importlib._bootstrap_external>", line 728, in exec_moduleFile "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "migrations\env.py", line 96, in <module>run_migrations_online()File "migrations\env.py", line 90, in run_migrations_onlinecontext.run_migrations()File "<string>", line 8, in run_migrationsFile "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\runtime\environment.py", line 846, in run_migrationsself.get_context().run_migrations(**kw)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\runtime\migration.py", line 520, in run_migrationsstep.migration_fn(**kw)File "D:\python_code\Day18\FlaskModel\migrations\versions\28db8668d325_.py", line 27, in upgradesa.PrimaryKeyConstraint('id')File "<string>", line 8, in create_tableFile "<string>", line 3, in create_tableFile "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\operations\ops.py", line 1252, in create_tablereturn operations.invoke(op)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\operations\base.py", line 374, in invokereturn fn(self, operation)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\operations\toimpl.py", line 101, in create_tableoperations.impl.create_table(table)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\ddl\impl.py", line 258, in create_tableself._exec(schema.CreateTable(table))File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\alembic\ddl\impl.py", line 140, in _execreturn conn.execute(construct, *multiparams, **params)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\sqlalchemy\engine\base.py", line 1020, in executereturn meth(self, multiparams, params)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\sqlalchemy\sql\ddl.py", line 72, in _execute_on_connectionreturn connection._execute_ddl(self, multiparams, params)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\sqlalchemy\engine\base.py", line 1082, in _execute_ddlcompiled,File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\sqlalchemy\engine\base.py", line 1324, in _execute_contexte, statement, parameters, cursor, contextFile "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\sqlalchemy\engine\base.py", line 1518, in _handle_dbapi_exceptionsqlalchemy_exception, with_traceback=exc_info[2], from_=eFile "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\sqlalchemy\util\compat.py", line 178, in raise_raise exceptionFile "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\sqlalchemy\engine\base.py", line 1284, in _execute_contextcursor, statement, parameters, contextFile "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\sqlalchemy\engine\default.py", line 590, in do_executecursor.execute(statement, parameters)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\pymysql\cursors.py", line 170, in executeresult = self._query(query)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\pymysql\cursors.py", line 328, in _queryconn.query(q)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\pymysql\connections.py", line 517, in queryself._affected_rows = self._read_query_result(unbuffered=unbuffered)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\pymysql\connections.py", line 732, in _read_query_resultresult.read()File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\pymysql\connections.py", line 1075, in readfirst_packet = self.connection._read_packet()File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\pymysql\connections.py", line 684, in _read_packetpacket.check_error()File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\pymysql\protocol.py", line 220, in check_errorerr.raise_mysql_exception(self._data)File "D:\Program Files\anaconda3\envs\FlaskModel\lib\site-packages\pymysql\err.py", line 109, in raise_mysql_exceptionraise errorclass(errno, errval)
sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1050, "Table 'usermodel' already exists")
[SQL:
CREATE TABLE `UserModel` (id INTEGER NOT NULL AUTO_INCREMENT,u_name VARCHAR(16),u_des VARCHAR(128),u_phone VARCHAR(128),u_addr VARCHAR(128),PRIMARY KEY (id)
)]

结果原来是table_name必须是小写才能完成修改,因为迁移创建表的时候会将表名转为小写,但是 sqlalchemy是会区分大小写的,所以会认为新建了表


http://www.ppmy.cn/news/523304.html

相关文章

500 Internal Server Error错误问题解决办法

这两天遇见两次页面报 500 Internal Server Error错误问题,网上找了许多答案都未能解决问题&#xff0c;如图&#xff1a; 最后找到原因&#xff1a; 本地服务端正常&#xff0c;由于该数据调用的是第三方接口&#xff0c;次数第三方接口服务已经停止运行&#xff0c;所有导致…

附加数据库失败错误5120 错误950

附加数据库时遇见两个问题&#xff1a; 1.错误代码5120 解决方式&#xff1a;这个错误是没有操作权限&#xff0c;要检查文件是否可读&#xff0c;安全性是否有权限。 2.错误代码950 版本问题。 数据库属性中可以查看当前sql server可以兼容的版本&#xff0c;如果还原的mdf文…

acedssget返回错误码-5001原因

原因可能是没有指定过滤机对象 也可能是对象dwgin out函数有问题&#xff01;

Mysql之1050错误解决办法

1050错误产生原因&#xff1a; 1.主从数据结构中&#xff0c;主库新建a表操作&#xff0c;从库已有a表&#xff1b; 2.单表中&#xff0c;建表重复&#xff0c;建议新建表最好使用 create table xx if no exist; 解决办法&#xff1a; 1.从库drop table a&#xff1b;删除原先表…

ERROR 1045 (28000): Access denied for user...错误的解决

刚连上数据库&#xff0c;第二天又连不上了&#xff0c;navicat 报错1045,到网上百度了一番&#xff0c;说是和sqlserver有关系&#xff0c;我就把sqlserver服务都改成手动的了&#xff0c;还是不行。明明是密码都正确&#xff0c;可就是连接不上&#xff0c;后来就去改密码了&…

计算机用户来源分析,中国PC用户购买渠道调查报告前期准备用户篇

第1页&#xff1a;近八成用户近期打算购买电脑 电脑产品品牌众多、型号让人眼花缭乱&#xff0c;用户在选购产品之前&#xff0c;通常会花费一定时间去对市场进行前期了解&#xff0c;以便选购更加适合自己的产品。 为了解用户在购买不同电脑产品时对渠道选择的特征&#xff0c…

比较好的论坛(个人认为)

1. 新浪论坛 推荐度&#xff1a;★★★★★ 特点&#xff1a;地球人都知道。。 最喜爱的版块&#xff1a;文化、it业界、读书、体育 网址&#xff1a;bbs.sina.com.cn 2.凯迪社区 推荐度&#xff1a;★★★★★ 特点&#xff1a;人气旺&#xff01;&#xff01;&#xff…

对于攒机的一些建议及经验之谈

在攒机区当版主有一段时间了,发现许多网友一上来发帖就说"我想攒个电脑&#xff0c;请大家推荐一个.""我有3000元,请版主给个配置"... 如此类似的问题看到的多了,回答的多了,我发现了一些问题. 一般来说,上来直接问配置的帖子,不予以回答.至于为什么不回答…