首页 > 数据库 >python: generator IDAL and DAL using sql server 2019

python: generator IDAL and DAL using sql server 2019

时间:2024-11-19 21:07:08浏览次数:1  
标签:info return generator python self server li def cls

 

create IDAL

# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# OS        : windows 10
# Datetime  : 2024/11/18 21:10
# User      : geovindu
# Product   : PyCharm
# Project   : pyGenerator
# File      : SqlServerGenerator/createInterface.py
# explain   : 学习
import os
import re
import sys
import io
import datetime
from common.fileHelper import FileHelper
from common.strHelper import StrHelper
from bll.tableNameAndKey import TableNameAndKeyBll
from bll.tableForegin import TableForeginBll
from bll.tableModel import TableModelBll

class CreateInterface(object):
    """

    """

    def __init__(self):
        self.__modelpath = os.path.join(os.getcwd() + "/test/interface/")
        self.__file = FileHelper()
        self.__blltablekey = TableNameAndKeyBll()
        self.__database = "sql server 2019"
        self.__name = "CreateInterface"
        pass

    def __del__(self):
        """

        :return:
        """
        print(f"{self.__name} ERASE MEMORY")
    def addpackagefile(self):
        """
        生成包配置文件
        :return:
        """
        now = datetime.datetime.now()
        bll = TableNameAndKeyBll()
        sb = []
        sbt = f"""
# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# OS        : windows 10
# Datetime  : {now.strftime('%Y-%m-%d %H:%M:%S')}
# database  :{self.__database}
# User      : geovindu
# Product   : PyCharm
# Project   : IctGame
# File      : interface/__init__.py
# explain   : 学习
                    """
        sb.append(sbt)
        for li in bll.selectSql():
            sbp=f"""
from interface.{StrHelper.firstLower(li.TableName)} import I{li.TableName}
"""
            sb.append(sbp)
        if not os.path.exists(self.__modelpath):
            os.makedirs(self.__modelpath)
        filepath = self.__modelpath + '__init__.py'
        content = ''.join(sb)
        ok = self.__file.createModelFile(filepath, content)

    def add(self):
        """
        生成实体
        :return:
        """
        # fileHelper=FileHelper()
        now = datetime.datetime.now()
        bll = TableNameAndKeyBll()
        for li in bll.selectSql():
            sb = []
            sbt = f"""
# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# OS        : windows 10
# Datetime  : {now.strftime('%Y-%m-%d %H:%M:%S')}
# database  :{self.__database}
# User      : geovindu
# Product   : PyCharm
# Project   : IctGame
# File      : interface/{li.TableName}.py
# explain   : 学习
from __future__ import annotations
from abc import ABC, abstractmethod
import os
import sys
from model.{StrHelper.firstLower(li.TableName)} import {li.TableName}Info

class I{li.TableName}(ABC):
    \"""
    {li.TableDescription}                    
    \""" 
"""
            sb.append(sbt)
            tbll = TableModelBll()
            sinhead = f"""
    @classmethod
    def __subclasshook__(cls, subclass):
        return (hasattr(subclass, 'load_data_source') and
                callable(subclass.load_data_source) and
                hasattr(subclass, 'extract_text') and
                callable(subclass.extract_text) or
                NotImplemented)  
                
    @abstractmethod
    def selectSql(cls) -> list:
        \"""

        :return:
        \"""
        pass

    @abstractmethod
    def selectSqlCount(cls) -> list:
        \"""
        查询数据 总数
        :return:
        \"""
        pass

    @abstractmethod
    def selectSqlOrder(cls, order: str) -> list:
        \"""

        :param order:
        :return:
        \"""
        pass

    @abstractmethod
    def selectSort(cls,field:str,isOrder:bool)->list:
        \"""

        :param field 
        :param order:  desc/asc
        :return:
        \"""
        pass

    @abstractmethod
    def selectIdSql(cls, {StrHelper.firstLower(li.FieldName)}: str):
        \"""

        :param {li.FieldName}:
        :return:
        \"""
        pass

    @abstractmethod
    def selectProc(cls):
        \"""

        :return:
        \"""
        pass

    @abstractmethod
    def selectIdProc(cls, {StrHelper.firstLower(li.FieldName)}):
        \"""

        :param {li.FieldName}:
        :return:
        \"""
        pass

    @abstractmethod
    def addSql(cls, info: {li.TableName}Info):
        \"""

        :param info:
        :return:
        \"""
        pass

    @abstractmethod
    def addProc(cls, info: {li.TableName}Info):
        \"""

        :param info:
        :return:
        \"""
        pass

    @abstractmethod
    def addOutProc(cls, info: {li.TableName}Info):
        \"""

        :param info:
        :return:
        \"""
        pass

    @abstractmethod
    def editSql(cls, info: {li.TableName}Info):
        \"""

        :param info:
        :return:
        \"""
        pass

    @abstractmethod
    def editProc(cls, info: {li.TableName}Info):
        \"""

        :param info:
        :return:
        \"""
        pass

    @abstractmethod
    def delSql(cls, {StrHelper.firstLower(li.FieldName)}):
        \"""

        :param {li.FieldName}:
        :return:
        \"""
        pass

    @abstractmethod
    def delProc(cls, {StrHelper.firstLower(li.FieldName)}):
        \"""

        :param {li.FieldName}:
        :return:
        \"""
        pass               
    """
            sb.append(sinhead)




            if not os.path.exists(self.__modelpath):
                os.makedirs(self.__modelpath)
            filepath = self.__modelpath + StrHelper.firstLower(li.TableName) + '.py'
            content = ''.join(sb)
            ok = self.__file.createModelFile(filepath, content)

  

create DAL 

# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# OS        : windows 10
# Datetime  : 2024/11/18 21:10
# User      : geovindu
# Product   : PyCharm
# Project   : pyGenerator
# File      : SqlServerGenerator/createDal.py
# explain   : 学习
import os
import re
import sys
import io
import datetime
from common.fileHelper import FileHelper
from common.strHelper import StrHelper
from bll.tableNameAndKey import TableNameAndKeyBll
from bll.tableForegin import TableForeginBll
from bll.tableModel import TableModelBll

class CreateDal(object):
    """

    """

    def __init__(self):
        self.__modelpath = os.path.join(os.getcwd() + "/test/dal/")
        self.__file = FileHelper()
        self.__blltablekey = TableNameAndKeyBll()
        self.__bllTableModel = TableModelBll()
        self.__database = "sql server 2019"
        self.__name = "CreateDal"
        pass

    def __del__(self):
        """

        :return:
        """
        print(f"{self.__name} ERASE MEMORY")

    def getColumn(self,tableName:str) -> str:
        """
         column=("SchoolId","SchoolName","SchoolTelNo")
        :return:
        """
        tables = self.__bllTableModel.selectSql(tableName)
        columns = []
        columnstr = '('
        if len(tables) > 0:
            for obj in tables:
                columns.append("\""+obj.FieldName+"\"")
            columnstr =columnstr + ','.join(columns)
        return columnstr+')'


    def getVales(self,tableName:str) -> str:
        """
        egs:
        vales=[info.SchoolId,info.SchoolName,info.SchoolTelNo]
        :return:
        """
        vales = []
        valesstr = '['
        tables = self.__bllTableModel.selectSql(tableName)
        if len(tables)>0:
            for obj in tables:
                vales.append('info.'+obj.FieldName)
            valesstr = valesstr+','.join(vales)
        return valesstr + ']'


    def getArgs(self,tableName:str) -> str:
        """
        egs:
        args = [info.SchoolId,info.SchoolName,info.SchoolTelNo] #修改的
        args ={{"schoolId":f"{{info.schoolId}}","SchoolName":f"{{info.SchoolName}}","SchoolTelNo":f"{{info.SchoolTelNo}}"}}
        :return:
        """
        args = []
        argsstr = '['
        tables = self.__bllTableModel.selectSql(tableName)
        if len(tables)>0:
            for obj in tables:
                args.append('info.'+obj.FieldName)
            argsstr =argsstr+ ','.join(args)
        return argsstr+']'

    def getArgs(self,tableName:str) -> str:
        """
        egs:
        args = [info.SchoolId,info.SchoolName,info.SchoolTelNo] #修改的
        :return:
        """
        args = []
        argsstr = '['
        tables = self.__bllTableModel.selectSql(tableName)
        if len(tables)>0:
            for obj in tables:
                args.append('info.'+obj.FieldName)
            argsstr = argsstr+','.join(args)
        return argsstr+']'

    def getArgsVariable(self,tableName:str) -> str:
        """
        egs:
        args ={"schoolId":f"{{info.schoolId}}","SchoolName":f"{{info.SchoolName}}","SchoolTelNo":f"{{info.SchoolTelNo}}"}}
        :return:
        """
        args = []
        argsstr = '{'
        tables = self.__bllTableModel.selectSql(tableName)
        if len(tables)>0:
            for obj in tables:
                args.append("\""+obj.FieldName+"\":f\"{info."+obj.FieldName+"}\"")
            argsstr =argsstr+ ','.join(args)
        return argsstr+'}'

    def getArgsOut(self,tableName:str, primekey:str) -> str:
        """
        egs:
        args = [info.SchoolName, info.SchoolTelNo,outid]   #添加返回值
        :return:
        """
        args = []
        argsstr = '['
        tables = self.__bllTableModel.selectSql(tableName)
        if len(tables)>0:
            for obj in tables:
                if str(obj.FieldName).lower() != primekey.lower():
                    args.append('info.'+obj.FieldName)
            argsstr = argsstr+','.join(args)
        return argsstr+',out'+primekey+']'



    def addpackagefile(self):
        """
        生成包配置文件
        :return:
        """
        now = datetime.datetime.now()
        bll = TableNameAndKeyBll()
        sb = []
        sbt = f"""
# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# OS        : windows 10
# Datetime  : {now.strftime('%Y-%m-%d %H:%M:%S')}
# database  :{self.__database}
# User      : geovindu
# Product   : PyCharm
# Project   : IctGame
# File      : dal/__init__.py
# explain   : 学习
                    """
        sb.append(sbt)
        for li in bll.selectSql():
            sbp=f"""
from dal.{StrHelper.firstLower(li.TableName)} import {li.TableName}Dal
"""
            sb.append(sbp)
        if not os.path.exists(self.__modelpath):
            os.makedirs(self.__modelpath)
        filepath = self.__modelpath + '__init__.py'
        content = ''.join(sb)
        ok = self.__file.createModelFile(filepath, content)


    def add(self):
        """
        生成实体
        :return:
        """
        # fileHelper=FileHelper()
        now = datetime.datetime.now()
        bll = TableNameAndKeyBll()
        for li in bll.selectSql():
            sb = []
            sbt = f"""
# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# OS        : windows 10
# Datetime  : {now.strftime('%Y-%m-%d %H:%M:%S')}
# database  :{self.__database}
# User      : geovindu
# Product   : PyCharm
# Project   : IctGame
# File      : dal/{li.TableName}.py
# explain   : 学习
from __future__ import annotations
from abc import ABC, abstractmethod
import os
import sys
from model.{StrHelper.firstLower(li.TableName)} import {li.TableName}Info
from DBUtility.MsSQLHelper import MsSqlHelper
from interface.{StrHelper.firstLower(li.TableName)} import I{li.TableName}

class {li.TableName}Dal(I{li.TableName}):
    \"""
    {li.TableDescription}                    
    \""" 
"""
            sb.append(sbt)
            sinhead = f"""
    myms = MsSqlHelper()
    def __init__(self):
         \"""
         构造函数,方法
         :param strserver:
         :param struser:
         :param strpwd:
         :param strdatabase:
         \"""
         self._strserver = ""
         self._struser = ""
         self._strpwd = ""
         self._strdatabase =""

    def selectSql(cls)->list:
         \"""
         查询数据 self._strserver, self._struser, self._strpwd, self._strdatabase
         :return:
         \"""
         row=cls.myms.execute("select * from {li.TableName};")
         #cls.myms.close()
         return row

    def selectSqlCount(cls)->list:
         \"""
         查询数据 总数
         :return:
         \"""

         row=cls.myms.execute("select count(*) as total from {li.TableName};")
         #cls.myms.close()
         return row[0]


    def selectSqlOrder(cls,order:str)->list:
         \"""
         :param order:  SchoolId desc/asc
         :return:
         \"""
         students=[]

         strsql=f"select * from {li.TableName} order by {{order}};"
         row=cls.myms.execute(f"select * from {li.TableName} order by {{order}};")
         return row

    def selectSort(cls,field:str,isOrder:bool)->list:
         \"""
         :param field {li.FieldName}
         :param order:  desc/asc
         :return:
         \"""
         order='desc'
         if isOrder==True:
             order='desc'
         else:
             order='asc'
         strsql=f"select * from {li.TableName} order by {{field}} {{order}};"
         row=cls.myms.execute(f"select * from {li.TableName} order by {{field}} {{order}};")
         #cls.myms.close()
         return row


    def selectIdSql(cls,{li.FieldName}:str)->list:
         \"""

         :param {li.FieldName}: 主键ID
         :return:
         \"""

         row=cls.myms.execute(f"select * from {li.TableName} where SchoolId='{{SchoolId}}';")  #考虑数据类型
         #cls.myms.close()
         return row

    def selectProc(cls)->list:
         \"""
         存储过程
         :return:
         \"""

         args = ()
         row = cls.myms.executeCallProc("procSelect{li.TableName}All",args)
         return row

    def selectIdProc(cls,{li.FieldName}:str)->list:
         \"""
         存储过程
         :param {li.FieldName}: 主键ID
         :return:
         \"""

         args = ({li.FieldName},)
         row = cls.myms.executeCallProc('procSelect{li.TableName}', args)
         return row

    def addSql(cls,info:{li.TableName}Info)->int:
          \"""
          添加,要考虑添加返回ID值
          :param info:实体类
          :return:
          \"""

          column={self.getColumn(li.TableName)}
          vales={self.getVales(li.TableName)}
          return cls.myms.insertByColumnaAndValues("{li.TableName}",column,vales)

    def addProc(cls,info:{li.TableName}Info)->int:
          \"""
          添加,要考虑添加返回ID值
          :param info:实体类
          :return:
          \"""

          args={self.getArgs(li.TableName)}
          return cls.myms.insertCallProc("procInsert{li.TableName}",args)

    def addOutProc(cls,info:{li.TableName}Info) -> int:
          \"""
          添加,要考虑添加返回ID值
          :param info:实体类
          :return: 返回增加的ID
          \"""
          id = 0
          try:

              outid =('int',) #输出,元组类型
              print(info)
              args = {self.getArgsOut(li.TableName,li.FieldName)}
              print(args)
              result=cls.myms.insertOutCallProc("procInsert{li.TableName}Output", args)
              print(result)
              id = result
          except Exception as ex:
              print(ex)
          return id

    def editSql(cls,info:{li.TableName}Info)->int:
        \"""

        :param info:实体类
        :return:
        \"""

        args = {self.getArgsVariable(li.TableName)}
        where = f"{li.FieldName}={{info.{li.FieldName}}}" #
        #print(args,where)
        return cls.myms.updateByKeyValues("{li.TableName}",where,args)

    def editProc(cls, info: {li.TableName}Info)->int:
         \"""

         :param info: 实体类
         :return:
         \"""

         args = {self.getArgs(li.TableName)}
         return cls.myms.updateProc("procUpdate{li.TableName}",args)


    def delSql(cls,{li.FieldName}:str)->int:
       \"""
       sql语句删除
       :param {li.FieldName}: 主键ID
       :return:
       \"""

       where={{f"{li.FieldName}":{li.FieldName}}}
       return cls.myms.deleteByKeyValues("{li.TableName}",where)

    def delProc(cls, {li.FieldName}:str)->int:
        \"""
        删除 存储过程 删除多个ID,后面增加
        :param {li.FieldName}: 主键ID
        :return:
        \"""
        args ={li.FieldName}
        k=cls.myms.deleteProc("procDuDelete{li.TableName}", args)
        return k            
"""
            sb.append(sinhead)
            if not os.path.exists(self.__modelpath):
                os.makedirs(self.__modelpath)
            filepath = self.__modelpath + StrHelper.firstLower(li.TableName) + '.py'
            content = ''.join(sb)
            ok = self.__file.createModelFile(filepath, content)

  

生成的代码:

# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# OS        : windows 10
# Datetime  : 2024-11-19 21:12:32
# database  :sql server 2019
# User      : geovindu
# Product   : PyCharm
# Project   : IctGame
# File      : interface/School.py
# explain   : 学习
from __future__ import annotations
from abc import ABC, abstractmethod
import os
import sys
from model.school import SchoolInfo

class ISchool(ABC):
    """
    学校表                    
    """ 

    @classmethod
    def __subclasshook__(cls, subclass):
        return (hasattr(subclass, 'load_data_source') and
                callable(subclass.load_data_source) and
                hasattr(subclass, 'extract_text') and
                callable(subclass.extract_text) or
                NotImplemented)  
                
    @abstractmethod
    def selectSql(cls) -> list:
        """

        :return:
        """
        pass

    @abstractmethod
    def selectSqlCount(cls) -> list:
        """
        查询数据 总数
        :return:
        """
        pass

    @abstractmethod
    def selectSqlOrder(cls, order: str) -> list:
        """

        :param order:
        :return:
        """
        pass

    @abstractmethod
    def selectSort(cls,field:str,isOrder:bool)->list:
        """

        :param field 
        :param order:  desc/asc
        :return:
        """
        pass

    @abstractmethod
    def selectIdSql(cls, schoolId: str):
        """

        :param SchoolId:
        :return:
        """
        pass

    @abstractmethod
    def selectProc(cls):
        """

        :return:
        """
        pass

    @abstractmethod
    def selectIdProc(cls, schoolId):
        """

        :param SchoolId:
        :return:
        """
        pass

    @abstractmethod
    def addSql(cls, info: SchoolInfo):
        """

        :param info:
        :return:
        """
        pass

    @abstractmethod
    def addProc(cls, info: SchoolInfo):
        """

        :param info:
        :return:
        """
        pass

    @abstractmethod
    def addOutProc(cls, info: SchoolInfo):
        """

        :param info:
        :return:
        """
        pass

    @abstractmethod
    def editSql(cls, info: SchoolInfo):
        """

        :param info:
        :return:
        """
        pass

    @abstractmethod
    def editProc(cls, info: SchoolInfo):
        """

        :param info:
        :return:
        """
        pass

    @abstractmethod
    def delSql(cls, schoolId):
        """

        :param SchoolId:
        :return:
        """
        pass

    @abstractmethod
    def delProc(cls, schoolId):
        """

        :param SchoolId:
        :return:
        """
        pass               
    

  

# encoding: utf-8
# 版权所有 2024 ©涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2023.1 python 3.11
# OS        : windows 10
# Datetime  : 2024-11-19 21:12:32
# database  :sql server 2019
# User      : geovindu
# Product   : PyCharm
# Project   : IctGame
# File      : dal/School.py
# explain   : 学习
from __future__ import annotations
from abc import ABC, abstractmethod
import os
import sys
from model.school import SchoolInfo
from DBUtility.MsSQLHelper import MsSqlHelper
from interface.school import ISchool

class SchoolDal(ISchool):
    """
    学校表                    
    """ 

    myms = MsSqlHelper()
    def __init__(self):
         """
         构造函数,方法
         :param strserver:
         :param struser:
         :param strpwd:
         :param strdatabase:
         """
         self._strserver = ""
         self._struser = ""
         self._strpwd = ""
         self._strdatabase =""

    def selectSql(cls)->list:
         """
         查询数据 self._strserver, self._struser, self._strpwd, self._strdatabase
         :return:
         """
         row=cls.myms.execute("select * from School;")
         #cls.myms.close()
         return row

    def selectSqlCount(cls)->list:
         """
         查询数据 总数
         :return:
         """

         row=cls.myms.execute("select count(*) as total from School;")
         #cls.myms.close()
         return row[0]


    def selectSqlOrder(cls,order:str)->list:
         """
         :param order:  SchoolId desc/asc
         :return:
         """
         students=[]

         strsql=f"select * from School order by {order};"
         row=cls.myms.execute(f"select * from School order by {order};")
         return row

    def selectSort(cls,field:str,isOrder:bool)->list:
         """
         :param field SchoolId
         :param order:  desc/asc
         :return:
         """
         order='desc'
         if isOrder==True:
             order='desc'
         else:
             order='asc'
         strsql=f"select * from School order by {field} {order};"
         row=cls.myms.execute(f"select * from School order by {field} {order};")
         #cls.myms.close()
         return row


    def selectIdSql(cls,SchoolId:str)->list:
         """

         :param SchoolId: 主键ID
         :return:
         """

         row=cls.myms.execute(f"select * from School where SchoolId='{SchoolId}';")  #考虑数据类型
         #cls.myms.close()
         return row

    def selectProc(cls)->list:
         """
         存储过程
         :return:
         """

         args = ()
         row = cls.myms.executeCallProc("procSelectSchoolAll",args)
         return row

    def selectIdProc(cls,SchoolId:str)->list:
         """
         存储过程
         :param SchoolId: 主键ID
         :return:
         """

         args = (SchoolId,)
         row = cls.myms.executeCallProc('procSelectSchool', args)
         return row

    def addSql(cls,info:SchoolInfo)->int:
          """
          添加,要考虑添加返回ID值
          :param info:实体类
          :return:
          """

          column=("SchoolId","SchoolName","SchoolTelNo")
          vales=[info.SchoolId,info.SchoolName,info.SchoolTelNo]
          return cls.myms.insertByColumnaAndValues("School",column,vales)

    def addProc(cls,info:SchoolInfo)->int:
          """
          添加,要考虑添加返回ID值
          :param info:实体类
          :return:
          """

          args=[info.SchoolId,info.SchoolName,info.SchoolTelNo]
          return cls.myms.insertCallProc("procInsertSchool",args)

    def addOutProc(cls,info:SchoolInfo) -> int:
          """
          添加,要考虑添加返回ID值
          :param info:实体类
          :return: 返回增加的ID
          """
          id = 0
          try:

              outid =('int',) #输出,元组类型
              print(info)
              args = [info.SchoolName,info.SchoolTelNo,outSchoolId]
              print(args)
              result=cls.myms.insertOutCallProc("procInsertSchoolOutput", args)
              print(result)
              id = result
          except Exception as ex:
              print(ex)
          return id

    def editSql(cls,info:SchoolInfo)->int:
        """

        :param info:实体类
        :return:
        """

        args = {"SchoolId":f"{info.SchoolId}","SchoolName":f"{info.SchoolName}","SchoolTelNo":f"{info.SchoolTelNo}"}
        where = f"SchoolId={info.SchoolId}" #
        #print(args,where)
        return cls.myms.updateByKeyValues("School",where,args)

    def editProc(cls, info: SchoolInfo)->int:
         """

         :param info: 实体类
         :return:
         """

         args = [info.SchoolId,info.SchoolName,info.SchoolTelNo]
         return cls.myms.updateProc("procUpdateSchool",args)


    def delSql(cls,SchoolId:str)->int:
       """
       sql语句删除
       :param SchoolId: 主键ID
       :return:
       """

       where={f"SchoolId":SchoolId}
       return cls.myms.deleteByKeyValues("School",where)

    def delProc(cls, SchoolId:str)->int:
        """
        删除 存储过程 删除多个ID,后面增加
        :param SchoolId: 主键ID
        :return:
        """
        args =SchoolId
        k=cls.myms.deleteProc("procDuDeleteSchool", args)
        return k            

  

 

 

标签:info,return,generator,python,self,server,li,def,cls
From: https://www.cnblogs.com/geovindu/p/18555611

相关文章

  • Python-开发运动会计分管理软件
    PYTHON-开发运动会计分管理软件项目概述1.软件功能我们的运动会计分管理软件具有以下功能:添加运动员:提供接口让用户输入运动员的基本信息,包括分组、姓名、名次。管理分组:支持创建、修改和删除运动员分组,方便组织和查看。得分计算:根据运动员名次自动计算得分,并在用户界面中......
  • Python 时间模块(time,datetime)
    在Python中,time模块和datetime模块都与时间处理相关,但它们有着不同的特点和用途,以下为你详细介绍:一.time模块概述:time模块提供了各种与时间相关的函数,它主要围绕着时间戳(从1970年1月1日00:00:00UTC到某个时刻所经过的秒数)来进行操作,常用于获取当前时间、对时间进......
  • 解释爬虫的基本概念,以及它的作用,并讲解如何使用 Python 实现网络爬虫。
    爬虫是一种自动化程序,用于从互联网上收集数据。它通过模拟人类访问网页的行为,自动发送HTTP请求,获取网页内容,并抽取所需的数据。爬虫的作用非常广泛。它可以用于搜索引擎的网页索引,获取新闻、博客等网页内容,进行数据挖掘和分析,监测网站的变化等。Python是一种常用的编程语言......
  • Zmap+python脚本+burp实现自动化Fuzzing测试
    声明学习视频来自B站UP主泷羽sec,如涉及侵权马上删除文章。笔记的只是方便各位师傅学习知识,以下网站只涉及学习内容,其他的都与本人无关,切莫逾越法律红线,否则后果自负。✍......
  • 计算机毕设项目源代码 python基于python的旅游可视化系统
    标题: python基于python的旅游可视化系统设计一个基于Python的旅游可视化系统,可以帮助用户更好地规划旅行路线,了解目的地的详细信息,并提供丰富的互动功能。以下是一个典型的旅游可视化系统的主要功能模块:1.系统概述•目标:为用户提供一个直观、易用的旅游信息平台,帮助用户......
  • 计算机毕设源码 python-基于flask在线考试系统
    标题:python-基于flask在线考试系统设计一个基于Flask框架的在线考试系统,需要考虑考生、教师和管理员的不同需求,确保系统的易用性、公平性和安全性。以下是一个典型的在线考试系统的主要功能模块:1.用户注册与登录•注册:用户可以通过手机号码、邮箱或社交账号注册。•登录:用......
  • 计算机毕设设计项目 python基于flask框架的车联网数据库系统的构建
    标题:python基于flask框架的车联网数据库系设计一个基于Flask框架的车联网数据库系统,需要考虑车辆数据的收集、存储、分析和管理,确保系统的高效性、可靠性和扩展性。以下是一个典型的车联网数据库系统的主要功能模块:1.用户注册与登录•注册:用户可以通过手机号码、邮箱或社......
  • 计算机毕设设计项目 python基于flask的校园失物招领系统设计与实现
    标题: python基于flask的校园失物招领系统设计设计一个基于Flask框架的校园失物招领系统,需要考虑学生、教师和其他校园成员的需求,确保系统的易用性、高效性和安全性。以下是一个典型的校园失物招领系统的主要功能模块:1.用户注册与登录•注册:用户可以通过手机号码、学号/工......
  • conda linux 管理python 环境
    一、conda是什么?Conda是一个开源的软件包管理系统和环境管理系统,用于在不同的操作系统上安装、运行和管理多个软件包和环境。它可以用于管理Python软件包和其他编程语言的软件包,具有自动解决依赖关系、创建独立环境、轻松切换环境等功能。Conda提供了一个命令行界面和一个图形界......
  • python中的模块、库、包有什么区别?
    Python用得多了,少不了和这几个概念打交道,但别说初学者了,很多老程序员一开始也迷糊。这不,有不少人都是“模块”、“库”随便混着叫,甚至把“包”也拉下水。今天咱们就来掰扯清楚这三者的区别和用法。模块:文件级别的组织首先,Python的“模块”指的是一个文件,也就是.py结尾的......