Python 链接数据库: 需要先安装pymysql 包 可以设置中安装,也可以pip install pymysql 安装 加载驱动: import pymysql # 需要先安装pymysql 包 可以设置中安装,也可以pip install pymysql 安装 conn = pymysql.connect(host=', db='s3') # 加载驱动 #cursor = conn.cursor() # 创建游标 cursor = conn.cursor(cursor=pymysql.c…
templates 讲后台得到的数据渲染到页面上:话不多说,先看具体代码. urls: from django.conf.urls import url from django.contrib import admin from django.urls import path from a00 import views urlpatterns = [ path('admin/', admin.site.urls), url(r'show_time/',views.show_time ), url…
Django框架中的urls配置: 首先通过pycharm创建一个Django项目: 例如要写blog的功能:则在digango_lesson中的urls代码如下: """django_lesson URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.0/topics…
多表查询: 内连接查询: 首先:创建两个表一个为tableA,一个为tableB,并且插入数据(代码省略) 同时查询两个表的记录: select * from tableA,tableB; 根据tableA中id 等于 tableB 中refer_id 进行内连接查询: select * from tableA,tableB where tableA.id=tableB.refer_id; 也可以用一下方法进行内连接查询: select * from tableB inner join tabl…
外键:主要是关联两个表的 举个栗子:在建表中创建外键 -- 添加外键例子 CREATE TABLE teacher( id TINYINT PRIMARY KEY auto_increment, name ), age int, is_marryed boolean ); CREATE TABLE student( id TINYINT PRIMARY KEY auto_increment, name ), charger_id TINYINT, FOREIGN KEY (charger_id)…
记录基本操作: 增:(insert into) 基本语法: insert into 表名(字段) values(对应字段的值): 例子1: insert into employee(id,name,age,salary) values(1,"憨憨",24,5000); 指定添加insert into employee values(2,"憨憨",0,24,"技术部",5000); 对应添加 insert into employee set nam…
计算所居住房子的面积 普通写法 class Room: def __init__(self,name,owner,width,length,heigh): self.name=name self.owner=owner self.width=width self.lenth=length self.heigh=heigh def cal_area(self): print('%s 住的 %s 总面积为 %s' %(self.owner,self.name,self.heigh*self.widt…
一.线程间的通信 实例代码: 需求是:输入一个姓名和性别后,就输出一个姓名和性别 class Resource { String name; String sex ; } class Input implements Runnable { Resource r; Input(Resource r) { this.r = r; } public void run() { int x = 0; while(true) { synchronized (r) { if(x==0) { r.name =…
风炫安全WEB安全学习第二十六节课 XSS常见绕过防御技巧 XSS绕过-过滤-编码 核心思想 后台过滤了特殊字符,比如说…
转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线教程的编写,以及yarn的翻译整理表示感谢. NeHe OpenGL第二十六课:反射 剪裁平面,蒙板缓存和反射: 在这一课中你将学会如何创建镜面显示效果,它使用剪裁平面,蒙板缓存等OpenGL中一些高级的技巧.   欢迎来到另一个激动人心的课程,这课的代码是Banu Cosmin所写,当然教程还是我…