-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb_query.py
More file actions
executable file
·52 lines (44 loc) · 1.12 KB
/
Copy pathdb_query.py
File metadata and controls
executable file
·52 lines (44 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python
import sys
sys.path.insert(0, "../config/")
sys.path.insert(0, "../ucloudbiz/")
import ucloudbiz
import urllib2
import urllib
import hashlib
import hmac
import base64
import urlparse
import linecache
import url_config
import ast
fabricurl=url_config.fabric_url
hagroupname='edu_ucloudbiz_XX_hagroup!'
sec='1' # 1 (public access), 0 (private access)
mode='3' # 2 (Read mode), 3 (Read/Write mode)
finalurl = fabricurl + 'grpcode=' + hagroupname + "&sec=" + sec + "&mode=" + mode
res=urllib2.urlopen(finalurl)
codes = res.read().replace('\u0000','').replace('null','').replace('(', '').replace(')', '')
result=ast.literal_eval(codes)
lst=result['code'].split(':')
res.close()
import MySQLdb as mdb
import sys
hostip=lst[0]
portno=int(lst[1])
username='root'
password='admin12345'
database='sakila'
sql="select title, release_year from film limit 5"
print
print "Host IP = %s" % hostip
print "Host Port = %s" % portno
print
con = mdb.connect(host=hostip, port=portno, user=username, passwd=password, db=database);
cur = con.cursor()
cur.execute(sql)
rows = cur.fetchall()
for row in rows:
print row
con.close()
print