admin 管理员组文章数量: 887021
2024年1月13日发(作者:matlab eval)
def __getitem__(self,key):if type(key)==type('abc'):return ueByName(key)if type(key)==type(1):theFld = elds[key]return ueByName(theFld)return None#设置属性值,key可以是索引,也可以是属性名.def __setitem__(self,key,value):if type(key)==type('abc'):ueByName(key,value)if type(key)==type(1):theFld = elds[key]ueByName(theFld,value)#获取实体的表名.def GetTableName(self):theType = type(self)if hasattr(theType,'TableName'):return getattr(theType,'TableName')return ''#获取关键字段名def GetKeyField(self):theType = type(self)if hasattr(theType,'KeyField'):return getattr(theType,'KeyField')return ''#获取字段名集合def GetFields(self):theType = type(self)if hasattr(theType,'Fields'):return getattr(theType,'Fields')return []InsertCondition = ion()InsertLockSign = False
if (theSQL==None or theSQL==''):theTableName=leName()theFields=lds()if theTableName=='' or theFields==[]:raise CustomError('表名或字段为空!')theSQL='INSERT INTO '+ theTableNametheFlds=''theVals=''theFldParams = ldParams()for theF in theFields:if theFlds=='':theFlds += theFtheVals += theFldParams[theF]['DSFmt']else:theFlds += ','+theFtheVals +=','+theFldParams[theF]['DSFmt']theSQL+='('+theFlds+') values('+theVals+')'self._SetClassValue(SqlName,theSQL)return theSQLfinally:InsertLockSign=()e()else:return theSQL#获取根据主键删除SQLdef GetDelByPKSQL(self):theSQL =self._GetClassValue(KSqlName)if (theSQL==None or theSQL==''):e()try:if LockSign:()DeleteLockSign = True
theSQL =self._GetClassValue(KSqlName)if (theSQL==None or theSQL==''):theTableName=leName()theKeyField=Field()if theTableName=='' or theKeyField=='':raise CustomError('表名或主键为空!')theFldParams = ldParams()theSQL='DELETE FROM '+ theTableName+' WHERE'+theKeyField+'='+theFldParams[theKeyField]['DSFmt']self._SetClassValue(KSqlName,theSQL)return theSQLfinally:DeleteLockSign=()e()else:return theSQL#获取更新所有字段的SQL语句(根据主键更新)def GetUpdateAllSQL(self):theSQL =self._GetClassValue(AllSqlName)if (theSQL==None or theSQL==''):e()try:if AllLockSign:()UpdateAllLockSign = TruetheSQL =self._GetClassValue(AllSqlName)if (theSQL==None or theSQL==''):theTableName=leName()theFields=lds()theKeyField=Field()if theTableName=='' or theFields==[] or theKeyField=='':raise CustomError('表名、主键或字段为空!')theSQL='UPDATE '+ theTableName +' SET '
'DataType':'varchar','Length':50,'Precision':0,'Scale':0},'USR_PWD':{'DSFmt':'%s','DataType':'varchar','Length':50,'Precision':0,'Scale':0}}
版权声明:本文标题:python定义实体类_[Python]一个简单的pythonMVC框架(1) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1705102474h473302.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论