基于Dragonboard 410c实现sqlite3数据库存储与管理
同样我们可以对表中数据进行读取操作:
def getUserAvatarImg(self,userID):
format="select avatarImg from userInfo where userID==%u"
values=(userID)
querySQL=format % values
print(querySQL)
self.cu.execute(querySQL)
result=self.cu.fetchone()
if result==None:
return -1
else:
return result[0]
还可以对表中数据进行插入操作
def insertTestData(self,userInfo_n,pushInfo_n):
for userID in range(1,userInfo_n):
format="test%u"
values=(userID)
userName=format % values
format="password_test%u"
password=format % values
format="email_test%uqq.com"
userEmail=format % values
format="phone_test%u"
userPhone=format % values
format="haarValue_test%u"
haarValues=format % values
avatar=(random.randint(1,8))
format="./avatarImg/headImg/ali1/%u.gif"
avatarImg=format % avatar
format="insert into userInfo values(%u,'%s','%s','%s','%s','%s','%s')"
values=(userID,userName,password,userEmail,userPhone,haarValues,avatarImg)
insertSQL=format % values
#print(insertSQL)
self.cu.execute(insertSQL)
for infoID in range(1,pushInfo_n):
ownerID=random.randint(1,userInfo_n)
pushID=random.randint(1,userInfo_n)
infoType=random.randint(0,1)
isTop=random.randint(0,1)
viewWeight=random.randint(1,8)
format = "infoSubject_pID:%u_wID:%u"
values=(pushID,ownerID)
infoSubject=format % values
format = "infoContent_pID:%u_wID:%u"
values=(pushID,ownerID)
infoContent=format % values
filePath=""
if infoType==1:
format="./messageFile/ownerID%u/pushID%u_%u.mp4"
values=(ownerID,pushID,infoID)
filePath=format % values
else:
filePath="None"
pushTIme=TIme.time()
format="insert into pushInfo values(%u,%u,%u,%u,'%s','%s','%s',%f,1.0,%u,%u)"
values=(infoID,ownerID,pushID,infoType,infoSubject,infoContent,filePath,pushTime,isTop,viewWeight)
insertSQL=format % values
#print(insertSQL)
self.DB.execute(insertSQL)
DragonBoard 410c SQlite 相关文章: