数数虚拟维度表导入脚本
This commit is contained in:
parent
7ca2be49a1
commit
b2ea4a87b7
54
ops/ss_virtual_create.py
Normal file
54
ops/ss_virtual_create.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
from urllib.parse import unquote, quote, urlencode
|
||||||
|
import pdb
|
||||||
|
|
||||||
|
|
||||||
|
def my_quote(data):
|
||||||
|
if isinstance(data, dict):
|
||||||
|
return urlencode(data)
|
||||||
|
elif isinstance(data, str):
|
||||||
|
return quote(data)
|
||||||
|
|
||||||
|
|
||||||
|
class SS_Virtual_command:
|
||||||
|
def __init__(self):
|
||||||
|
self.ss_virtual_url = "https://10.10.3.17:8992/v1/ta/meta/prop/virtual/dict/create"
|
||||||
|
self.method = "post"
|
||||||
|
|
||||||
|
|
||||||
|
def upload(self, filename):
|
||||||
|
|
||||||
|
projectId = int(19)
|
||||||
|
createParam = {"commonHeader": {"projectId": 19},
|
||||||
|
"mainColumn": {"property": {"columnName": "gameid", "tableType": 0}},
|
||||||
|
"columns": [{"property": {"columnName": "gameid", "columnDesc": "主键ID", "selectType": "number"}},
|
||||||
|
{"property": {"columnName": "gameid_china", "columnDesc": "china映射", "selectType": "string"}}]}
|
||||||
|
loginName = "root"
|
||||||
|
password = "kingsome2016"
|
||||||
|
pdb.set_trace()
|
||||||
|
body = {"projectId": projectId, "createParam": createParam, "loginName": loginName, "password": password}
|
||||||
|
quote_body = my_quote(body)
|
||||||
|
|
||||||
|
r = requests.post(url=self.ss_virtual_url, header="Accept: application/json", files=filename, data=quote_body)
|
||||||
|
if r.status_code == requests.codes.ok:
|
||||||
|
print(f"upload success,return={r.content}")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print(f"upload failed,return={r.content}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
raise Exception("PLS input filename which need upload!")
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
ss = SS_Virtual_command()
|
||||||
|
ss.upload(filename)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user