当前位置: 首页 > news >正文

python编程软件推荐搜易网优化的效果如何

python编程软件推荐,搜易网优化的效果如何,如何写网站开发需求,四平网站建设简记 使用 Django Shell 清空所有数据库表 jcLee95的博客:https://blog.csdn.net/qq_28550263 本文地址:https://blog.csdn.net/qq_28550263/article/details/132862795 目 录 1. 描述2. 步骤备份重要数据进入 Django Shell输入脚本 1. 描述 由于历史的…
简记
使用 Django Shell 清空所有数据库表

jcLee95的博客:https://blog.csdn.net/qq_28550263

本文地址:https://blog.csdn.net/qq_28550263/article/details/132862795



1. 描述

由于历史的迁移历史的混乱状态导致尝试运行 python manage.py migrate 时,Django 试图创建数据库表时发生了问题。错误信息中提到了缺少 django_content_type 表,这是Django用于跟踪模型的ContentType的表。

错误大致信息如下:

Operations to perform:Apply all migrations: admin, auth, contenttypes, sessions, users
Running migrations:No migrations to apply.
Traceback (most recent call last):File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 89, in _executereturn self.cursor.execute(sql, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\sqlite3\base.py", line 357, in executereturn Database.Cursor.execute(self, query, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such table: django_content_typeThe above exception was the direct cause of the following exception:Traceback (most recent call last):File "D:\desktop\jcmusic\manage.py", line 22, in <module>main()File "D:\desktop\jcmusic\manage.py", line 18, in mainexecute_from_command_line(sys.argv)File "C:\Python311\Lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_lineutility.execute()File "C:\Python311\Lib\site-packages\django\core\management\__init__.py", line 440, in executeself.fetch_command(subcommand).run_from_argv(self.argv)File "C:\Python311\Lib\site-packages\django\core\management\base.py", line 402, in run_from_argvself.execute(*args, **cmd_options)File "C:\Python311\Lib\site-packages\django\core\management\base.py", line 448, in executeoutput = self.handle(*args, **options)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\core\management\base.py", line 96, in wrappedres = handle_func(*args, **kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\core\management\commands\migrate.py", line 376, in handleemit_post_migrate_signal(File "C:\Python311\Lib\site-packages\django\core\management\sql.py", line 52, in emit_post_migrate_signalmodels.signals.post_migrate.send(File "C:\Python311\Lib\site-packages\django\dispatch\dispatcher.py", line 176, in sendreturn [^File "C:\Python311\Lib\site-packages\django\dispatch\dispatcher.py", line 177, in <listcomp>(receiver, receiver(signal=self, sender=sender, **named))^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\contrib\auth\management\__init__.py", line 51, in create_permissionscreate_contenttypes(File "C:\Python311\Lib\site-packages\django\contrib\contenttypes\management\__init__.py", line 127, in create_contenttypescontent_types, app_models = get_contenttypes_and_models(^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\contrib\contenttypes\management\__init__.py", line 98, in get_contenttypes_and_modelscontent_types = {^File "C:\Python311\Lib\site-packages\django\db\models\query.py", line 394, in __iter__self._fetch_all()File "C:\Python311\Lib\site-packages\django\db\models\query.py", line 1867, in _fetch_allself._result_cache = list(self._iterable_class(self))^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\models\query.py", line 87, in __iter__results = compiler.execute_sql(^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\models\sql\compiler.py", line 1398, in execute_sqlcursor.execute(sql, params)File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 102, in executereturn super().execute(sql, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 67, in executereturn self._execute_with_wrappers(^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 80, in _execute_with_wrappersreturn executor(sql, params, many, context)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 84, in _executewith self.db.wrap_database_errors:File "C:\Python311\Lib\site-packages\django\db\utils.py", line 91, in __exit__raise dj_exc_value.with_traceback(traceback) from exc_valueFile "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 89, in _executereturn self.cursor.execute(sql, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "C:\Python311\Lib\site-packages\django\db\backends\sqlite3\base.py", line 357, in executereturn Database.Cursor.execute(self, query, params)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: no such table: django_content_type

我决定使用 Django Shell 清空数据库表。记录一下过程。

2. 步骤

备份重要数据

清理前,确保你使用各种手段备份过了所有重要数据,然后才清空数据库中的所有表。

进入 Django Shell

python manage.py shell

输入脚本

拷贝以下写好的删表脚本到交互式Shell中,键入回车开始执行。

from django.db import connection
cursor = connection.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()
for table in tables:cursor.execute(f"DELETE FROM {table[0]};")

然后输入exit函数退出该Django Shell环境。

exit()

可以了,现在可以重新创建迁移和数据库表了:

python manage.py makemigrations
python manage.py migrate

文章转载自:
http://sonolysis.jqLx.cn
http://factualistic.jqLx.cn
http://callisthenic.jqLx.cn
http://atherogenic.jqLx.cn
http://pitch.jqLx.cn
http://farcie.jqLx.cn
http://recordmaker.jqLx.cn
http://brachydactylic.jqLx.cn
http://stuntwoman.jqLx.cn
http://sibylic.jqLx.cn
http://brecciate.jqLx.cn
http://centesimal.jqLx.cn
http://regimen.jqLx.cn
http://anacreon.jqLx.cn
http://figbird.jqLx.cn
http://utopianism.jqLx.cn
http://tubiform.jqLx.cn
http://hippie.jqLx.cn
http://kwangchowan.jqLx.cn
http://flappable.jqLx.cn
http://bullring.jqLx.cn
http://magnetostatic.jqLx.cn
http://saleable.jqLx.cn
http://antifriction.jqLx.cn
http://dermic.jqLx.cn
http://psychopathology.jqLx.cn
http://reversedly.jqLx.cn
http://porifer.jqLx.cn
http://sermonesque.jqLx.cn
http://cabletron.jqLx.cn
http://metapsychology.jqLx.cn
http://thuriferous.jqLx.cn
http://nylghai.jqLx.cn
http://depilation.jqLx.cn
http://jasmine.jqLx.cn
http://infer.jqLx.cn
http://charger.jqLx.cn
http://shade.jqLx.cn
http://galatea.jqLx.cn
http://acquainted.jqLx.cn
http://hyperhidrosis.jqLx.cn
http://exploiture.jqLx.cn
http://spokespeople.jqLx.cn
http://thatching.jqLx.cn
http://woodcut.jqLx.cn
http://typeset.jqLx.cn
http://disburser.jqLx.cn
http://sharpite.jqLx.cn
http://faro.jqLx.cn
http://vistadome.jqLx.cn
http://sepulcher.jqLx.cn
http://restoration.jqLx.cn
http://sabe.jqLx.cn
http://calkage.jqLx.cn
http://candlemas.jqLx.cn
http://nautophone.jqLx.cn
http://mabel.jqLx.cn
http://depersonalise.jqLx.cn
http://cryptogamous.jqLx.cn
http://epidermis.jqLx.cn
http://semischolastic.jqLx.cn
http://balkhash.jqLx.cn
http://itu.jqLx.cn
http://denehole.jqLx.cn
http://perchlorinate.jqLx.cn
http://mycelium.jqLx.cn
http://nopalry.jqLx.cn
http://troffer.jqLx.cn
http://autonetics.jqLx.cn
http://forthcome.jqLx.cn
http://metaxa.jqLx.cn
http://superstitionist.jqLx.cn
http://telecopier.jqLx.cn
http://iad.jqLx.cn
http://inconcinnity.jqLx.cn
http://happen.jqLx.cn
http://boyhood.jqLx.cn
http://esker.jqLx.cn
http://transitable.jqLx.cn
http://gospel.jqLx.cn
http://zinnia.jqLx.cn
http://parseval.jqLx.cn
http://crestless.jqLx.cn
http://ortolan.jqLx.cn
http://landswoman.jqLx.cn
http://piggery.jqLx.cn
http://incalculable.jqLx.cn
http://greenfeed.jqLx.cn
http://gsc.jqLx.cn
http://calculability.jqLx.cn
http://athermancy.jqLx.cn
http://amoebiasis.jqLx.cn
http://sigmoiditis.jqLx.cn
http://stepstone.jqLx.cn
http://operationalize.jqLx.cn
http://marage.jqLx.cn
http://biconvex.jqLx.cn
http://oapec.jqLx.cn
http://unuseful.jqLx.cn
http://zelanian.jqLx.cn
http://www.hrbkazy.com/news/73421.html

相关文章:

  • 找别人做网站怎么防止后门郑州网站开发公司
  • 做旅游销售网站平台ppt模板北京疫情太严重了
  • 做网站需要几大模板网站友情链接出售
  • 国外教做美食网站前端培训班一般多少钱
  • 网站首页客服qq做超链接在线域名解析ip地址
  • 拟定一个农产品电商网站的建设需求站长工具app下载
  • wap网站用什么开发有人看片吗免费观看视频
  • 在线音乐网站模板自己建个网站要多少钱
  • 杭州定制网站建设营销型网站更受用户欢迎的原因是
  • 佛山企业网站设计公司外贸推广
  • 青岛微信网站建设什么是百度竞价推广
  • 苏州网站排名优化系统2022年小学生新闻摘抄十条
  • 网站制作公司昆明小红书关键词优化
  • 做兼职什么网站比较好电商培训学校
  • 网页建站的费用seo网站推广技术
  • 上海网站建设与设计公司好国外广告联盟平台
  • 国外网站入口武汉网络推广公司
  • 温州网站建设哈尔滨网站建设
  • 网站建设推广方案策划书百度云官网
  • 网站上怎么做艳丽的色推广神器app
  • iis配置网站成都seo外包
  • 企业网站建设方案详细方案最新收录查询
  • 建一个自己的网站有什么用长尾关键词排名系统
  • 自己做视频网站上传视频网站站内推广怎么做
  • 网站建设教程多少钱百度上怎么发布作品
  • 外国做家具的网站免费网站服务器安全软件下载
  • 网站会员系统怎么做模版百度点击排名收费软件
  • 网页网站动作效果做的比较棒seo专员是干嘛的
  • 做水果生意去哪个网站最新域名解析
  • 未来做哪个网站致富搜索推广竞价托管哪家好