Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TestAuto
InterfaceAutoTest
Commits
c588a69b
Commit
c588a69b
authored
Apr 30, 2021
by
huangchengcheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into master
parents
5f36f135
a65312d3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
2 deletions
+64
-2
common/db.py
+63
-1
service/login.py
+1
-1
No files found.
common/db.py
View file @
c588a69b
import
redis
import
redis
,
pymysql
# redis类
class
RedisBase
:
...
...
@@ -17,9 +17,70 @@ class RedisString(RedisBase):
return
result
# mysql类
class
MYSQL
:
"""
对pymysql的简单封装
"""
def
__init__
(
self
,
host
,
port
,
user
,
pwd
,
db
):
self
.
host
=
host
self
.
port
=
port
self
.
user
=
user
self
.
pwd
=
pwd
self
.
db
=
db
def
__GetConnect
(
self
):
"""
得到连接信息
返回: conn.cursor()
"""
self
.
conn
=
pymysql
.
connect
(
host
=
self
.
host
,
port
=
self
.
port
,
user
=
self
.
user
,
password
=
self
.
pwd
,
database
=
self
.
db
,
charset
=
"utf8"
)
cur
=
self
.
conn
.
cursor
()
return
cur
def
ExecuQuery
(
self
,
sql
):
"""
执行查询语句
返回的是一个包含tuple的list,list的元素是记录行,tuple的元素是每行记录的字段
调用示例:
ms = MYSQL(host="localhost",user="sa",pwd="123456",db="PythonWeiboStatistics")
resList = ms.ExecQuery("SELECT id,NickName FROM WeiBoUser")
for (id,NickName) in resList:
print str(id),NickName
"""
cur
=
self
.
__GetConnect
()
cur
.
execute
(
sql
)
resList
=
cur
.
fetchall
()
#查询所有,得到列表 [(1,2,3),(1,2,3),(1,2,3)]
# resList = cur.fetchone() # 查询一个,得到1个(不用这个)
#查询完毕后必须关闭连接
self
.
conn
.
close
()
return
resList
def
ExecuNonQuery
(
self
,
sql
):
"""
执行非查询语句
调用示例:
cur = self.__GetConnect()
cur.execute(sql)
self.conn.commit()
self.conn.close()
"""
cur
=
self
.
__GetConnect
()
cur
.
execute
(
sql
)
self
.
conn
.
commit
()
self
.
conn
.
close
()
if
__name__
==
'__main__'
:
# r= RedisString(6).get('bmc:captcha:bf46c0c0-11b4-4b7d-99d7-530f77f8ab88')
# r = RedisString(0).get('edl:sms_value:17822000010:MOBILE_REGISTER')
# print(r)
# print(str(r)[-7:-1])
pass
\ No newline at end of file
service/login.py
View file @
c588a69b
...
...
@@ -7,7 +7,7 @@ def sso_login():
def
bmy_login
():
"""企业云登录"""
"""
开发1112221
"""
"""
kkkk
"""
pass
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment