标签:HERE you tin pytho span 操作 方式 def zhang
import pymysql db = pymysql.connect(db= "guest", user="root", passwd="", host="127.0.0.1",) cursor = db.cursor() cursor.execute("select realname from sign_guest order by create_time") name = [row[0] for row in cursor.fetchall()] print(name) [‘张三‘, ‘李四‘, ‘康‘, ‘李五‘, ‘lily‘, ‘zhangailing‘, ‘dulala‘, ‘adu‘, ‘tester01‘, ‘tester01‘, ‘tester02‘, ‘andy‘, ‘vivian‘] 2~5 ---- 首先要连接db 6 ---- 然后获得db的执行器对象 7 ---- 然后通过执行器运行sql,此时cursor对象相当于一个容器,存放了执行sql的结果 8 ---- 最后从cursor中取出来数据
from django.db import models # Create your models here. class UserMessage(models.Model): # UserMessage对应db的表名 name = models.CharField(max_length=20, verbose_name="用户名") email = models.EmailField(verbose_name="邮箱") address = models.CharField(max_length=100, verbose_name="联系地址") message = models.CharField(max_length=500, verbose_name="留言信息") class Meta: verbose_name = "用户留言信息"
from django.db import models # Create your models here. class UserMessage(models.Model): # UserMessage对应db的表名 name = models.CharField(max_length=20, verbose_name="用户名") email = models.EmailField(verbose_name="邮箱") address = models.CharField(max_length=100, verbose_name="联系地址") message = models.CharField(max_length=500, verbose_name="留言信息") class Meta: verbose_name = "用户留言信息"
D:\myproject\djangopro1 (venv3) $ python manage.py makemigrations message System check identified some issues: WARNINGS: ?: (2_0.W001) Your URL pattern ‘^form/$‘ has a route that contains ‘(?P<‘, begins with a ‘^‘, or ends with a ‘$‘. This was likely an oversight when migrating to django.urls.path(). Migrations for ‘message‘: message\migrations\0001_initial.py - Create model UserMessage
D:\myproject\djangopro1 (venv3) $ python manage.py migrate message System check identified some issues: WARNINGS: ?: (2_0.W001) Your URL pattern ‘^form/$‘ has a route that contains ‘(?P<‘, begins with a ‘^‘, or ends with a ‘$‘. This was likely an oversight when migrating to django.urls.path(). Operations to perform: Apply all migrations: message Running migrations: Applying message.0001_initial... OK
标签:HERE you tin pytho span 操作 方式 def zhang
原文地址:https://www.cnblogs.com/kknote/p/11768365.html