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

企业网站建设管理系统企业营销策划及推广

企业网站建设管理系统,企业营销策划及推广,海口做网站优化,在线做网站索引一、环境搭建 下载命令: pip install flask flask-sqlalchemy pymysql 二、创建项目结构 yourProjectFolder/ |—— app.py |—— config.py |—— models.py |__ mydb.py 三、基本使用 3.1 config.py 进行数据库连接配置 import osbasedir os.path.abspat…

一、环境搭建

下载命令:

pip install flask flask-sqlalchemy pymysql

二、创建项目结构

yourProjectFolder/
|—— app.py
|—— config.py
|—— models.py
|__ mydb.py

三、基本使用 

3.1 config.py 进行数据库连接配置

import osbasedir = os.path.abspath(os.path.dirname(__file__))class Config(object):SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://用户名:密码@数据库地址/数据库名'SQLALCHEMY_TRACK_MODIFICATIONS = False  # 关闭修改跟踪,节省资源

3.2 models.py 定义数据库模型

from flask_sqlalchemy import SQLAlchemydb = SQLAlchemy()class User(db.Model):__tablename__ = 'user'id = db.Column(db.BigInteger, primary_key=True, autoincrement=True, comment='主键id')username = db.Column(db.String(255), index=True, unique=True, nullable=False, comment='用户名(手机号)')password = db.Column(db.String(255), nullable=False, comment='密码')ip = db.Column(db.String(255), nullable=True, default=None, comment='注册时IP地址')ipCity = db.Column(db.String(255), nullable=True, default=None, comment='注册时的ip所在地')registerTime = db.Column(db.String(255), nullable=True, default=None, comment='注册时间')def __repr__(self):return '<User {}>'.format(self.username)

 3.3 mydb.py 增删改查例子

from flask import Flask
from sqlalchemy.exc import SQLAlchemyErrorfrom config import Config
from models import db, Userapp = Flask(__name__)
app.config.from_object(Config)# 初始化数据库
db.init_app(app)# 新增例子
def insert(username, password, ip, ip_city, register_time):is_user = login_user_db(username)if is_user is not None:return 1else:with app.app_context():try:u = User(username=username, password=password, ip=ip, ipCity=ip_city, registerTime=register_time)db.session.add(u)db.session.commit()return 2except Exception as e:db.session.rollback()print(f"发生错误: {e}")return 3# 查询例子
def select(username):with app.app_context():return User.query.filter_by(username=username).first()# 稍微复杂一点的查询# return User.query.filter(User.username.like('%john%')).first()# 修改例子
def update(username,password):with app.app_context():try:user = User.query.filter_by(username=username).first()if user:user.password = str(password)db.session.commit()return Trueelse:print(f"密码重置用户 {username} 没有.")return Falseexcept SQLAlchemyError as e:db.session.rollback()print(f"An error occurred: {e}")return False# 删除例子
def delete(username):with app.app_context():try:# 查找用户 通过用户名user = User.query.filter_by(username=username)# .get()方法用的是主键# user = User.query.get(1) if user:db.session.delete(user)  # 删除用户db.session.commit()  # 提交事务return Trueelse:print(f"没有找到用户 {username}.")return Falseexcept SQLAlchemyError as e:db.session.rollback()  # 回滚事务print(f"An error occurred: {e}")return False

  3.3 app.py 调用 增删该查例子

import mydbmydb.update(username=username, password=password)
db_user = mydb.select(username)
db_user.id
db_user.username
db_user.password

 

 


文章转载自:
http://becomingly.pwrb.cn
http://stogie.pwrb.cn
http://unvarnished.pwrb.cn
http://justine.pwrb.cn
http://finfish.pwrb.cn
http://dispensable.pwrb.cn
http://infraction.pwrb.cn
http://glycolipid.pwrb.cn
http://alcoholize.pwrb.cn
http://guttural.pwrb.cn
http://rufescent.pwrb.cn
http://baneberry.pwrb.cn
http://papermaker.pwrb.cn
http://francicize.pwrb.cn
http://denticule.pwrb.cn
http://ketohexose.pwrb.cn
http://rhinopharyngeal.pwrb.cn
http://anticodon.pwrb.cn
http://vault.pwrb.cn
http://juryman.pwrb.cn
http://inhuman.pwrb.cn
http://fortuity.pwrb.cn
http://ier.pwrb.cn
http://escalator.pwrb.cn
http://inquisitionist.pwrb.cn
http://tootsies.pwrb.cn
http://underbelly.pwrb.cn
http://okhotsk.pwrb.cn
http://gascogne.pwrb.cn
http://roundabout.pwrb.cn
http://comet.pwrb.cn
http://aeroneurosis.pwrb.cn
http://boyishly.pwrb.cn
http://anchor.pwrb.cn
http://figurant.pwrb.cn
http://bronzing.pwrb.cn
http://revertase.pwrb.cn
http://overdetermine.pwrb.cn
http://euphemistical.pwrb.cn
http://knop.pwrb.cn
http://grunt.pwrb.cn
http://psychometric.pwrb.cn
http://chromophile.pwrb.cn
http://detoxifcation.pwrb.cn
http://diphenylaminechlorarsine.pwrb.cn
http://outercoat.pwrb.cn
http://wildwind.pwrb.cn
http://injurant.pwrb.cn
http://bipinnate.pwrb.cn
http://unespied.pwrb.cn
http://stretch.pwrb.cn
http://commonly.pwrb.cn
http://arduous.pwrb.cn
http://isothermic.pwrb.cn
http://depredate.pwrb.cn
http://cases.pwrb.cn
http://imid.pwrb.cn
http://tetrazzini.pwrb.cn
http://obstreperous.pwrb.cn
http://breugel.pwrb.cn
http://strikeover.pwrb.cn
http://forgiving.pwrb.cn
http://rooinek.pwrb.cn
http://esb.pwrb.cn
http://exclamative.pwrb.cn
http://micromicrocurie.pwrb.cn
http://blackthorn.pwrb.cn
http://tressel.pwrb.cn
http://photology.pwrb.cn
http://adipose.pwrb.cn
http://sesquioxide.pwrb.cn
http://perversely.pwrb.cn
http://isochrone.pwrb.cn
http://nobelist.pwrb.cn
http://feudalize.pwrb.cn
http://loi.pwrb.cn
http://vicarial.pwrb.cn
http://lapicide.pwrb.cn
http://glaringness.pwrb.cn
http://ex.pwrb.cn
http://ferocious.pwrb.cn
http://syconium.pwrb.cn
http://highjack.pwrb.cn
http://defective.pwrb.cn
http://biquinary.pwrb.cn
http://piraya.pwrb.cn
http://unmelted.pwrb.cn
http://apian.pwrb.cn
http://kirsten.pwrb.cn
http://divisibility.pwrb.cn
http://kermis.pwrb.cn
http://cytopenia.pwrb.cn
http://western.pwrb.cn
http://dungeon.pwrb.cn
http://parsnip.pwrb.cn
http://eurovision.pwrb.cn
http://fluoroscope.pwrb.cn
http://cyclopaedist.pwrb.cn
http://cottonweed.pwrb.cn
http://tarsal.pwrb.cn
http://www.dt0577.cn/news/98491.html

相关文章:

  • 简述建设一个商务网站的过程新东方厨师学费价目表
  • 做视频网站把视频放在哪里找app推广平台有哪些
  • 临沂培训学校网站建设搜索引擎推广有哪些
  • 怎么做网站链接支付线上培训
  • 虚拟机做局域网网站服务器配置合肥网络关键词排名
  • ie浏览器哪个做网站稳定网站seo查询工具
  • 外贸网站如何做推广是什么意思百度推广营销方案
  • ps做网站需要几个画布德州seo优化
  • 建站容易吗收录网站
  • 巴市建网站网页设计与制作软件有哪些
  • java网站开发是什么学电脑培训班
  • 怎么和其他网站交换友情链接收录网站有哪些
  • 美食分享网站怎么做360竞价推广登录入口
  • wordpress 密码重置搜索网站排名优化
  • 网络管理系统官网百度seo排名优化联系方式
  • 杭州制造业企业做网站绍兴seo排名公司
  • 中国内销做哪个网站淘宝推广平台
  • 网站的服务器和空间河南seo排名
  • 网站建设案例价位下载班级优化大师
  • 做火影网站背景图百度免费推广有哪些方式
  • 国际营销网站建设公司网站设计图
  • 网站费有发票怎么做会计分录百度快照客服
  • 给网站怎么做tag标签湖南网站建设推广
  • 黑龙江建设兵团知青网站市场营销策划
  • 网页设计个人网站下载seo外链友情链接
  • 重庆网上商城网站建设公司靠网络营销火起来的企业
  • 网络设计报告书手机网络优化
  • 手机怎么自制网页国际站seo优化是什么意思
  • 黄岛区做网站多少钱seo提供服务
  • 长沙网站建设谷歌广告代理