chore: snapshot production code before Apple Design UI refinement
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import pymysql, pathlib, re, json
|
||||
def connect():
|
||||
env={}
|
||||
for name in ['base.env','stat-writer.env']:
|
||||
for line in pathlib.Path('/opt/lingniu-go-native/env/'+name).read_text().splitlines():
|
||||
if '=' in line and not line.startswith('#'):
|
||||
k,v=line.split('=',1);env[k]=v.strip().strip('\"').strip("'")
|
||||
m=re.fullmatch(r'([^:]+):(.*?)@tcp\(([^:]+):(\d+)\)/([^?]+).*',env['MYSQL_DSN'])
|
||||
assert m, 'Unexpected DSN format'
|
||||
return pymysql.connect(user=m[1],password=m[2],host=m[3],port=int(m[4]),database=m[5],charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor,autocommit=False)
|
||||
if __name__=='__main__':
|
||||
c=connect()
|
||||
with c.cursor() as q:
|
||||
for table in ['vehicle_daily_mileage_source','vehicle_daily_mileage','vehicle_data_source','vehicle_identifier','vehicle']:
|
||||
q.execute('SHOW COLUMNS FROM '+table); print(table,json.dumps(q.fetchall(),default=str,ensure_ascii=False))
|
||||
q.execute("SELECT * FROM vehicle_data_source WHERE platform_name LIKE '%赛格%' OR source_code LIKE '%seg%' OR source_ip LIKE '%seg%'"); print('SEG_SOURCES',json.dumps(q.fetchall(),default=str,ensure_ascii=False))
|
||||
c.close()
|
||||
Reference in New Issue
Block a user