-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdatabase.py
More file actions
executable file
·93 lines (89 loc) · 2.14 KB
/
database.py
File metadata and controls
executable file
·93 lines (89 loc) · 2.14 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/python
import MySQLdb
from config import Config
class DB:
@staticmethod
def getConn():
conn = MySQLdb.connect (host = Config.host,
user = Config.username,
passwd = Config.password,
db = Config.database,
charset='utf8')
return conn
@staticmethod
def execute(c, sql, *args):
try:
if not args:
c.execute(sql)
else:
c.execute(sql, args[0])
except MySQLdb.Error as e:
print e
print sql
if args:
print args[0]
raise e
#@staticmethod
#def execute(c, sql, args):
# try:
# c.execute(sql, args)
# except _mysql_exceptions.OperationError as e:
# print e
# print sql, args
# raise e
#define table names and column indices
class repotype:
_table = "repotype_tbl"
id = 0
type = 1
_numColumns = 2
class repo:
_table = "repo_tbl"
id = 0
name = 1
repotypeid = 2
url = 3
viewlink = 4
tagname = 5
tagmaturity = 6
_numColumns = 7
class keyword:
_table = "keyword_tbl"
keyword = 0
parent = 1
type = 2
_numColumns = 3
class commit:
_table = "commit_tbl"
id = 0
repoid = 1
date = 2
message = 3
uniqueid = 4
_numColumns = 5
class commitfile:
_table = "commitfile_tbl"
commitid = 0
file = 1
_numColumns = 2
class commitkeyword:
_table = "commitkeyword_tbl"
commitid = 0
keyword = 1
_numColumns = 2
class commitdiffs:
_table = "commitdiffs_tbl"
commitid = 0
data = 1
_numColumns = 2
class commitwordmap:
_table = "commitwordmap_tbl"
commitid = 0
word = 1
_numColumns = 2
class searchqueries:
_table = "searchqueries_tbl"
timestamp = 0
ip = 1
terms = 2
_numColumns = 3