CoCalc Shared Fileswww / cgi-bin / mfd / fix.pyOpen in CoCalc with one click!
Author: William A. Stein
1
#!/usr/bin/python
2
3
import mfd, magma, constants, misc
4
5
import pg # postgresql access
6
db = pg.DB("modular")
7
8
query = "SELECT * FROM lratio_odd " # + " where mod_id=10106"
9
for x in db.query(query).dictresult():
10
id = x['mod_id']
11
num = misc.parse_sqlarray(x['numerator'])
12
denom = misc.parse_sqlarray(x['denominator'])
13
ans = []
14
for i in range(len(num)):
15
ans.append(misc.quotient_string(num[i],denom[i]))
16
s = str(ans)
17
s = s.replace("'", "\\'")
18
query = "UPDATE lratio_odd SET lratio_odd = '%s' where mod_id=%s"%(s,id)
19
db.query(query)
20
21
22
23
24