本文整理匯總了Python中MySQL.MySQL.create_connection方法的典型用法代碼示例。如果您正苦於以下問題:Python MySQL.create_connection方法的具體用法?Python MySQL.create_connection怎麽用?Python MySQL.create_connection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MySQL.MySQL
的用法示例。
在下文中一共展示了MySQL.create_connection方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: download_unprocessed_chromium_comments
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import create_connection [as 別名]
def download_unprocessed_chromium_comments(self,fptr, mysql_host, mysql_username, mysql_password, mysql_database, mysql_port):
lines = fptr.readlines()
filename = 'chromium_comments_unprocessed_' + str(int(time.time())) + '.txt'
fopen = open(filename, 'a')
chrome_sql_fopen = open('chromium_comments_sql_unprocessed_' + str(int(time.time())) + '.txt', 'a')
for line in lines:
issue_id = line.strip()
time.sleep(2)
try:
num_comments = self.get_num_comments(issue_id)
#print type(num_comments)
if num_comments != 0 :
query = self.comment_feed_url % (issue_id, num_comments)
request = urllib2.Request(query)
response = urllib2.urlopen(request)
text = response.read()
comment_feed = json.loads(text)
#print num_comments
comment_entries = comment_feed['feed']['entry']
for comment_entry in comment_entries:
try :
comment_id = comment_entry['id']['$t'].split('http://code.google.com/feeds/issues/p/chromium/issues/%s/comments/full/' % issue_id)[1]
#print issue_id, comment_id
except Exception, e:
print e
try:
published = datetime.strptime(comment_entry['published']['$t'].split(".")[0], "%Y-%m-%dT%H:%M:%S")
#print published
except:
published = None
pass
try:
updated = datetime.strptime(comment_entry['updated']['$t'].split(".")[0], "%Y-%m-%dT%H:%M:%S")
#print updated
except:
updated = None
pass
try:
title = comment_entry['title']['$t']
#print title
except:
title = None
try:
content = unicodedata.normalize('NFKD', comment_entry['content']['$t']).encode('ascii', 'ignore')
#print content
except :
content = None
try:
author = comment_entry['author'][0]['name']['$t']
except:
author = None
try :
issue_status = comment_entry['issues$updates']['issues$status']['$t']
#print issue_status
except :
issue_status = None
try :
owner_update = comment_entry['issues$updates']['issues$ownerUpdate']['$t']
#print owner_update
except :
owner_update = None
try :
M = MySQL(mysql_host, mysql_username, mysql_password, mysql_database, mysql_port)
#print M.host, M.username, M.passwd, M.db, M.port
connection, cursor = M.create_connection()
result = cursor.execute(self.insertCommentsQuery, (issue_id, comment_id, published, updated, title, content, author, issue_status, owner_update))
M.close_connection(cursor, connection)
except Exception, e:
#print e
#print 'Unprocessed - ' +str(issue_id)
chrome_sql_fopen.write(str(issue_id) + '\n')
開發者ID:Mining-multiple-repos-data,項目名稱:GoogleIssueTrackerDownload,代碼行數:93,代碼來源:ChromiumIssueTracker.py
示例2: download_android_comments
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import create_connection [as 別名]
def download_android_comments(self,start_issue_id, end_issue_id, mysql_host, mysql_username, mysql_password, mysql_database, mysql_port):
for issue_id in range(start_issue_id, end_issue_id + 1):
try:
num_comments = self.get_num_comments(issue_id)
query = self.comment_feed_url % (issue_id, num_comments)
request = urllib2.Request(query)
response = urllib2.urlopen(request)
text = response.read()
comment_feed = json.loads(text)
#print num_comments
comment_entries = comment_feed['feed']['entry']
for comment_entry in comment_entries:
try :
comment_id = comment_entry['id']['$t'].split('http://code.google.com/feeds/issues/p/android/issues/%s/comments/full/' % issue_id)[1]
#print issue_id, comment_id
except Exception, e:
#print e
print
try:
published = datetime.strptime(comment_entry['published']['$t'].split(".")[0], "%Y-%m-%dT%H:%M:%S")
#print published
except:
published = None
pass
try:
updated = datetime.strptime(comment_entry['updated']['$t'].split(".")[0], "%Y-%m-%dT%H:%M:%S")
#print updated
except:
updated = None
pass
try:
title = comment_entry['title']['$t']
#print title
except:
title = None
try:
content = unicodedata.normalize('NFKD', comment_entry['content']['$t']).encode('ascii', 'ignore')
#print content
except :
content = None
try:
author = comment_entry['author'][0]['name']['$t']
except:
author = None
try :
issue_status = comment_entry['issues$updates']['issues$status']['$t']
#print issue_status
except :
issue_status = None
try :
M = MySQL(mysql_host, mysql_username, mysql_password, mysql_database, mysql_port)
#print M.host, M.username, M.passwd, M.db, M.port
connection, cursor = M.create_connection()
result = cursor.execute(self.insertCommentsQuery, (issue_id, comment_id, published, updated, title, content, author, issue_status))
M.close_connection(cursor, connection)
except Exception, e:
#print e
#print 'Unprocessed - ' +str(issue_id)
filename = 'android_commentsql_unprocessed.txt'
fopen = open(filename, 'a')
fopen.write(str(issue_id) + '\n')
fopen.close()
開發者ID:Mining-multiple-repos-data,項目名稱:GoogleIssueTrackerDownload,代碼行數:79,代碼來源:AndroidIssueTracker.py
示例3: download_chromium_unprocessed_issue_reports
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import create_connection [as 別名]
#.........這裏部分代碼省略.........
if value.lower() == 'os':
if os:
os = os + ',' + label['$t'].split('-')[1]
else:
os = label['$t'].split('-')[1]
if value.lower() == 'area':
area = label['$t'].split('-')[1]
#print area, type(area)
if value.lower() == 'feature':
if feature:
feature = feature + ',' + label['$t'].lower().split('feature-')[1]
else:
feature = label['$t'].lower().split('feature-')[1]
if value.lower() == 'mstone':
mstone = label['$t'].split('-')[1]
#print mstone, type(mstone)
if value.lower() == 'releaseblock':
releaseBlock = label['$t'].split('-')[1]
#print releaseBlock
mod_label = unicodedata.normalize('NFKD', label['$t']).encode('ascii', 'ignore')
if mod_label.lower() == 'type-regression' or mod_label.lower() == "regression":
regression = True
if mod_label.lower() == "performance" or mod_label.lower() == "type-performance" or mod_label.lower() == "stability-performance":
performance = True
if mod_label.lower() == "cleanup" or mod_label.lower() == "type-cleanup":
cleanup = True
if mod_label.lower() == "polish" or mod_label.lower() == "type-polish" or mod_label.lower() == "stability-polish":
polish = True
if mod_label.lower() == "usability" or mod_label.lower() == "type-usability " or mod_label.lower() == "stability-usability":
usability = True
if mod_label.lower() == "crash" or mod_label.lower() == "type-crash" or mod_label.lower() == "stability-crash":
crash = True
if mod_label.lower() == "security" or mod_label.lower() == "type-security":
security = True
if value.lower() == 'secseverity':
secSeverity = label['$t'].split('-')[1]
#print issue_id, secSeverity, type(secSeverity)
if value.lower() == 'webkit':
if webkit:
webkit = webkit + ',' + label['$t'].lower().split('webkit-')[1]
else:
webkit = label['$t'].lower().split('webkit-')[1]
if value.lower() == 'hotlist':
hotlist = label['$t'].lower().split('hotlist-')[1]
if value.lower() == 'internals':
internals = label['$t'].split('Internals-')[1]
if value.lower() == 'sev':
sev = label['$t'].split('Sev-')[1]
if value.lower() == 'secimpacts':
secImpacts = label['$t'].split('SecImpacts-')[1]
if value.lower() == 'not':
if notLabel:
notLabel = notLabel + ',' + label['$t'].lower().split('not-')[1]
else:
notLabel = label['$t'].lower().split('not-')[1]
if value.lower() == 'action':
if action:
action = action + ',' + label['$t'].lower().split('action-')[1]
else:
action = label['$t'].lower().split('action-')[1]
except Exception, e:
print e
print 'No labels found ' + str(id)
pass
print issue_id, action
M = MySQL(mysql_host, mysql_username, mysql_password, mysql_database, mysql_port)
connection, cursor = M.create_connection()
result = cursor.execute(self.insertIssueQuery,(issue_id, title, state, content, stars, owner, blocking, blockedOn, updated, status, closedDate, mergedInto, cc, author, published, bugtype, priority, pri, os, area, feature, mstone, releaseBlock, regression, performance, cleanup, polish, usability, crash, security, secSeverity, webkit, hotlist, internals, sev, secImpacts, notLabel, action, num_comments))
M.close_connection(cursor, connection)
開發者ID:Mining-multiple-repos-data,項目名稱:GoogleIssueTrackerDownload,代碼行數:104,代碼來源:ChromiumIssueTracker.py
示例4: download_android_issue_reports
# 需要導入模塊: from MySQL import MySQL [as 別名]
# 或者: from MySQL.MySQL import create_connection [as 別名]
#.........這裏部分代碼省略.........
try :
labels = issue_report['issues$label']
# print labels
restrict = None
target = None
bugtype = None
securityProblem = False
reportedBy = None
component = None
cat = None
priority = None
version = None
subcomponentopengl = None
subcomponent = None
regression = False
for label in labels:
value = unicodedata.normalize('NFKD', label['$t'].split('-')[0]).encode('ascii', 'ignore')
#print value, type(value), value.lower() == 'type'
if value.lower() == 'restrict':
restrict = label['$t'].split('-')[1]
# print restrict
if value.lower() == 'target':
target = label['$t'].split('-')[1]
#print target
if value.lower() == 'type':
bugtype = label['$t'].split('-')[1]
# print type
if value.lower() == 'securityproblem':
securityProblem = True
# print securityProblem
if value.lower() == 'reportedby':
reportedBy = label['$t'].split('-')[1]
# print reportedBy
if value.lower() == 'component':
component = label['$t'].split('-')[1]
# print component
if value.lower() == 'cat':
cat = label['$t'].split('-')[1]
# print cat
if value.lower() == 'priority':
priority = label['$t'].split('-')[1]
# print priority
if value.lower() == 'version':
version = label['$t'].split('-')[1]
# print version
if value.lower() == 'subcomponentopengl':
subcomponentopengl = False
# print subcomponentopengl
if value.lower() == 'subcomponent':
subcomponent = label['$t'].split('-')[1]
# print subcomponent
if value.lower() == 'regression':
regression = True
# print regression'
except:
#print 'No labels found ' + str(id)
pass
# issue_query = insertQuery % (id, title, state, content, stars, owner, blocking, blockedOn, updated, status, closedDate, mergedInto, cc, author, published, restrict, target, securityProblem, reportedBy, component, cat, priority, version, subcomponentopengl, subcomponent, bugtype, regression)
M = MySQL(mysql_host, mysql_username, mysql_password, mysql_database, mysql_port)
#print M.host, M.username, M.passwd, M.db, M.port
connection, cursor = M.create_connection()
result = cursor.execute(self.insertQuery, (issue_id, title, state, content, stars, owner, blocking, blockedOn, updated, status, closedDate, mergedInto, cc, author, published, restrict, target, securityProblem, reportedBy, component, cat, priority, version, subcomponentopengl, subcomponent, bugtype, regression, num_comments))
M.close_connection(cursor, connection)
except Exception, e:
#print e
#print 'Unprocessed - ' +str(issue_id)
filename = 'android_issues_unprocessed.txt'
fopen = open(filename, 'a')
fopen.write(str(issue_id) + '\n')
fopen.close()
開發者ID:Mining-multiple-repos-data,項目名稱:GoogleIssueTrackerDownload,代碼行數:104,代碼來源:AndroidIssueTracker.py