-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMMICProgram.py
More file actions
67 lines (36 loc) · 1.15 KB
/
Copy pathMMICProgram.py
File metadata and controls
67 lines (36 loc) · 1.15 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
__author__ = 'adrianmo'
import string
import re
import codecs,sys, unicodedata
import pprint
import MySQLdb
import os
xuser = "root"
xpasswd = "cRe33Eth"
xhost = '127.0.0.1'
xport = 3334
class MMICProgram():
def openFile(self, fileName):
with codecs.open (fileName, "r", "utf-8") as line:
f = line.read()
self.code = f.splitlines()
print self.code
def getField(self, table, field, syid=1):
mega = MySQLdb.connect(host=xhost,port=xport,user=xuser, passwd=xpasswd,db='charls')
mega.autocommit(False)
c = mega.cursor()
c.execute("SET CHARACTER SET utf8")
c.execute("SET collation_connection = 'utf8_general_ci'")
c.execute("""SELECT %s FROM %s WHERE syid=%s order by reid asc """ % (field, table, syid))
mega.close()
rst = c.fetchall()
stringify = ""
for i in range(0,len(rst)):
stringify += rst[i][0] + "\n\r"
return stringify
def getCode(self):
file = ""
for i in self.code:
if isinstance(i, unicode):
file += "\n" + i
return file