Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: infra/tools/antibody/cloudsql_connect.py

Issue 1235373004: Added script to generate stats on a git checkout (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@new_antibody_db_schema
Patch Set: Rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « infra/tools/antibody/antibody.py ('k') | infra/tools/antibody/code_review_parse.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import sys 5 import sys
6 6
7 try: 7 try:
8 sys.path.append('/usr/lib/python2.7/dist-packages/') 8 sys.path.append('/usr/lib/python2.7/dist-packages/')
9 import MySQLdb 9 import MySQLdb
10 except ImportError: # pragma: no cover 10 except ImportError: # pragma: no cover
11 pass 11 pass
12 finally: 12 finally:
13 sys.path.remove('/usr/lib/python2.7/dist-packages/') 13 sys.path.remove('/usr/lib/python2.7/dist-packages/')
14 14
15 DB_INSTANCE_IP = '173.194.225.193' 15 DB_INSTANCE_IP = '173.194.225.193'
16 DEFAULT_DATABASE = 'ANTIBODY_DB' 16 DEFAULT_DATABASE = 'ANTIBODY_2'
17 USERNAME = 'antibody-team' 17 USERNAME = 'antibody-team'
18 18
19 19
20 def connect(password): # pragma: no cover 20 def connect(password): # pragma: no cover
21 """Connect to Cloud SQL instance google.com:antibody-978:antibody-sql""" 21 """Connect to Cloud SQL instance google.com:antibody-978:antibody-sql"""
22 connection = MySQLdb.connect(host=DB_INSTANCE_IP, 22 connection = MySQLdb.connect(host=DB_INSTANCE_IP,
23 user=USERNAME, passwd=password, 23 user=USERNAME, passwd=password,
24 db=DEFAULT_DATABASE) 24 db=DEFAULT_DATABASE)
25 cc = connection.cursor() 25 cc = connection.cursor()
26 return connection, cc 26 return connection, cc
(...skipping 14 matching lines...) Expand all
41 41
42 VARCHAR(200)|VARCHAR(40)|TIMESTAMP|VARCHAR(10) 42 VARCHAR(200)|VARCHAR(40)|TIMESTAMP|VARCHAR(10)
43 43
44 type: author or tbr 44 type: author or tbr
45 """ 45 """
46 cursor.executemany("""REPLACE INTO commit_people VALUES (%s,%s,%s,%s)""", 46 cursor.executemany("""REPLACE INTO commit_people VALUES (%s,%s,%s,%s)""",
47 rows) 47 rows)
48 48
49 49
50 def write_to_git_commit(cursor, rows): # pragma: no cover 50 def write_to_git_commit(cursor, rows): # pragma: no cover
51 """hash|bug_url|timestamp|review_url|project_prj_id 51 """hash|bug_url|timestamp|review_url|project_prj_id|subject
52 52
53 VARCHAR(40)|VARCHAR(200)|TIMESTAMP|VARCHAR(200)|INT 53 VARCHAR(40)|VARCHAR(200)|TIMESTAMP|VARCHAR(200)|INT|VARCHAR(500)
54 """ 54 """
55 cursor.executemany("""REPLACE INTO git_commit VALUES (%s,%s,%s,%s,%s)""", 55 cursor.executemany("""REPLACE INTO git_commit VALUES (%s,%s,%s,%s,%s,%s)""",
56 rows) 56 rows)
57 57
58 58
59 def write_to_people(cursor, rows): # pragma: no cover 59 def write_to_people(cursor, rows): # pragma: no cover
60 """email_address|committer_since 60 """email_address|committer_since
61 61
62 VARCHAR(200)|TIMESTAMP 62 VARCHAR(200)|TIMESTAMP
63 """ 63 """
64 cursor.execute("""REPLACE INTO people VALUES (%s,%s)""", rows) 64 cursor.execute("""REPLACE INTO people VALUES (%s,%s)""", rows)
65 65
(...skipping 27 matching lines...) Expand all
93 93
94 94
95 def commit(conn): # pragma: no cover 95 def commit(conn): # pragma: no cover
96 conn.commit() 96 conn.commit()
97 97
98 98
99 def close(conn, cursor): # pragma: no cover 99 def close(conn, cursor): # pragma: no cover
100 cursor.close() 100 cursor.close()
101 conn.commit() 101 conn.commit()
102 conn.close() 102 conn.close()
OLDNEW
« no previous file with comments | « infra/tools/antibody/antibody.py ('k') | infra/tools/antibody/code_review_parse.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698