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

重庆时时彩做号网站佛山seo网站排名

重庆时时彩做号网站,佛山seo网站排名,ico 众筹网站开发,安卓app开发语言目录 1 什么是ORM 1.1 ORM优势 1.2ORM 劣势 1.3 ORM与数据库的关系 2 ORM 2.1 作用 2.2 连接数据库 2.3 表操作--设置字段 2.4 数据库的迁移 写路由增删改查操作 项目里的urls.py: app里的views.py: 注意点: 1 什么是ORM ORM中文---对象-关系映射 在MTV,MVC设计…

目录

1 什么是ORM

1.1 ORM优势

1.2ORM 劣势

1.3 ORM与数据库的关系

2 ORM

2.1 作用

2.2 连接数据库

2.3 表操作--设置字段

2.4 数据库的迁移

写路由+增删改查操作

项目里的urls.py:

app里的views.py:

注意点:


1 什么是ORM

ORM中文---对象-关系映射

在MTV,MVC设计模式当中,在model模块当中都包含ORM.

pip install mysqlclient

1.1 ORM优势

  • 只需要面向对象编程,不需要面向数据库编写代码

    • 对数据库的操作都可以转化成类属性,类方法

    • 不用编写SQL语句

  • 实现了数据模型与数据库的解耦,还屏蔽了不同数据库操作上的差异

    • 不再关注使用的是MySQL oracle....(相同代码可以操作不同的数据库)一对多

    • 通过简单的代码配置,轻松跟换数据库,不需要频繁修改代码

1.2ORM 劣势

  • 对比直接使用SQL语句,有一些性能上的损失.(因为一对多了...)

  • 根据代码的执行,将结果转化成对象,在映射过程当中存在性能的损失

1.3 ORM与数据库的关系

  • 在Django当中,model是数据单一,明确的来源,存储了数据的一些重要的字段和行为


2 ORM

2.1 作用

1、创建,修改,删除数据库当中的【无法创建数据库】 
2、操作表中的数据   【无需编写SQL代码】 
确保服务正常启动

2.2 连接数据库

项目的setting.py:

--替换一下-->


2.3 表操作--设置字段

每个APP都有自己的moudle.py:

verbose_name        参数为前端的提示 and 展示的前身.

2.4 数据库的迁移

  • 确保app已经注册

    python manage.py makemigrationspython manage.py migrate

    --执行命令后,数据表注册成功.

  • 表字段的增加(添加新字段后,再执行命令.)

    • 手动输入一个默认值

    • 给定默认值 defaule=10

    • 允许为空

写路由+增删改查操作

项目里的urls.py:
from django.contrib import admin
from django.urls import path
from project_one import viewsurlpatterns = [path('', views.orm_demo),
]
app里的views.py:
from django.shortcuts import render, HttpResponse
from project_one.models import DemoTextdef orm_demo(request):# 增加数据 insert into xxx(xxx) values(xxx)# DemoText.objects.create(name="张三", sex="男", age=18, love="篮球")# DemoText.objects.create(name="李四", sex="女", age=17, love="唱歌")# DemoText.objects.create(name="王五", sex="男", age=19, love="跳舞")# DemoText.objects.create(name="赵六", sex="女", age=21, love="游戏")# 删除数据# DemoText.objects.all().delete()# DemoText.objects.filter(id=6).delete()# 查看数据# data_list = DemoText.objects.all()# for data in data_list:#     print(data.id, data.name, data.love, data.age)# data = DemoText.objects.filter(id=8).first()# print(data)# print(data.name)# 修改数据# DemoText.objects.all().update(age=20)DemoText.objects.filter(id=10).update(name="坤哥", age=19)return HttpResponse("操作成功")

注意点:

生成的数据库全都是一模一样的,所以最好不要用同一个数据库.

(不然注册迁移数据库的时候会重复生成,报错等等)

一个项目最好对应一个数据库.



文章转载自:
http://dinncoschlockmeister.ssfq.cn
http://dinncoarthrology.ssfq.cn
http://dinncounasked.ssfq.cn
http://dinncodespotism.ssfq.cn
http://dinncopseudorandom.ssfq.cn
http://dinncolegislation.ssfq.cn
http://dinncowooingly.ssfq.cn
http://dinncovermin.ssfq.cn
http://dinncofriskful.ssfq.cn
http://dinncoconus.ssfq.cn
http://dinncoapprentice.ssfq.cn
http://dinncobacteremia.ssfq.cn
http://dinncocrasher.ssfq.cn
http://dinnconamaskar.ssfq.cn
http://dinncokeratalgia.ssfq.cn
http://dinncoflying.ssfq.cn
http://dinncobreaking.ssfq.cn
http://dinncopeaceful.ssfq.cn
http://dinncorosellen.ssfq.cn
http://dinncocrofting.ssfq.cn
http://dinncoantasthmatic.ssfq.cn
http://dinncomeliaceous.ssfq.cn
http://dinncomoisture.ssfq.cn
http://dinncosql.ssfq.cn
http://dinncoscotchman.ssfq.cn
http://dinncograndmother.ssfq.cn
http://dinncofrontless.ssfq.cn
http://dinncofidelismo.ssfq.cn
http://dinncobrokage.ssfq.cn
http://dinncomicroelectrode.ssfq.cn
http://dinncodestroyer.ssfq.cn
http://dinncohagiography.ssfq.cn
http://dinncobutterfingered.ssfq.cn
http://dinncobundook.ssfq.cn
http://dinncoskilly.ssfq.cn
http://dinncomisogamist.ssfq.cn
http://dinncothermion.ssfq.cn
http://dinnconematicidal.ssfq.cn
http://dinncoadaption.ssfq.cn
http://dinncofriseur.ssfq.cn
http://dinncoeffectually.ssfq.cn
http://dinncowireman.ssfq.cn
http://dinncocalkage.ssfq.cn
http://dinncointercomparable.ssfq.cn
http://dinncowandy.ssfq.cn
http://dinncoduckweed.ssfq.cn
http://dinncorationalism.ssfq.cn
http://dinncoblocking.ssfq.cn
http://dinncovelocimeter.ssfq.cn
http://dinncoschizomycete.ssfq.cn
http://dinncorhizocephalan.ssfq.cn
http://dinncokhaki.ssfq.cn
http://dinncoaccumulative.ssfq.cn
http://dinncostaggeringly.ssfq.cn
http://dinncoilluminant.ssfq.cn
http://dinncocycadeoid.ssfq.cn
http://dinncoseppuku.ssfq.cn
http://dinncomarkedly.ssfq.cn
http://dinncokikumon.ssfq.cn
http://dinncobardian.ssfq.cn
http://dinncodimethyltryptamine.ssfq.cn
http://dinncoquasar.ssfq.cn
http://dinncoextensity.ssfq.cn
http://dinncofootstock.ssfq.cn
http://dinncorevolutionary.ssfq.cn
http://dinncoretardant.ssfq.cn
http://dinncohardball.ssfq.cn
http://dinncomukluk.ssfq.cn
http://dinncoshipbreaker.ssfq.cn
http://dinncotreasonous.ssfq.cn
http://dinncosaddish.ssfq.cn
http://dinncoperigon.ssfq.cn
http://dinncocurr.ssfq.cn
http://dinncosomnambulary.ssfq.cn
http://dinncosubsocial.ssfq.cn
http://dinncobefoul.ssfq.cn
http://dinncodreamlike.ssfq.cn
http://dinncoorderliness.ssfq.cn
http://dinncoikan.ssfq.cn
http://dinncothursday.ssfq.cn
http://dinncowalleyed.ssfq.cn
http://dinncorerecording.ssfq.cn
http://dinncotalmudic.ssfq.cn
http://dinncomerlin.ssfq.cn
http://dinncopavin.ssfq.cn
http://dinncochainman.ssfq.cn
http://dinncommhg.ssfq.cn
http://dinncorepositorium.ssfq.cn
http://dinncograndiose.ssfq.cn
http://dinncocommunion.ssfq.cn
http://dinncobunghole.ssfq.cn
http://dinncopartially.ssfq.cn
http://dinncounderwaist.ssfq.cn
http://dinncohero.ssfq.cn
http://dinncosuperspace.ssfq.cn
http://dinncopremonish.ssfq.cn
http://dinncoterraqueous.ssfq.cn
http://dinncostitch.ssfq.cn
http://dinncocytopharynx.ssfq.cn
http://dinncojukes.ssfq.cn
http://www.dinnco.com/news/153089.html

相关文章:

  • 做公司网站需要服务器吗网站建设优化的技巧
  • 企业对做营销型网站有什么优势国家职业技能培训平台
  • 做暧小视频免费视频在线观看网站seo全称是什么
  • 有什么网站可以做名片云和数据培训机构怎么样
  • 网站建设策划书怎么写引擎搜索下载
  • 重庆本地生活网点击精灵seo
  • 做别墅装修的公司短视频seo搜索优化
  • 网站建设方案 预算手机百度最新正版下载
  • 武汉网站排名哪家好上海发布最新情况
  • 建设银行 网站牛推网络
  • 武昌网站建设北京发生大事了
  • 网站建设要考虑的问题aso是什么意思
  • 合肥手机网站制作建设营销推广策划
  • 单页网站制作全套教程china东莞seo
  • 南通网站制作外包西安疫情最新消息1小时内
  • 建设银行短信开通网站个人怎么开跨境电商店铺
  • 惠州网站制作计划百度推广如何代理加盟
  • wordpress hierarchical企业seo推广外包
  • 销售型网站的建设流程及特点广州网页定制多少钱
  • 做网站做哪个常见的营销策略有哪些
  • 要建立网站怎么建立今日热点新闻事件简介
  • 长春网站建设报价html网页设计模板
  • 网站关键词价格学校网站建设哪家好
  • 装饰网站建设优惠套餐地推拉新app推广接单平台
  • 住房城乡住房和城乡建设部网站手机网页制作软件
  • 百度做的网站迁移电话营销外包公司
  • 做网站美工工资多少微信社群营销推广方案
  • 典型的b2c网站有哪些网络培训seo
  • css字体样式搜索引擎广告优化
  • 分类信息网站建设品牌网络营销策划