1c7 commented on issue #16398:
URL: https://github.com/apache/superset/issues/16398#issuecomment-1293583699

   @lziosi Very helpful! works for me!
   
   shorter example
   ```python
   def add_dataset(database_id, schema: 'mp_analytic', table_name):
     payload = {
       "database": database_id, # 数据库的 ID
       "schema": schema,
       "table_name": table_name # 数据库表名
     }
     url = f"{base}/api/v1/dataset/"
   
     session = requests.Session()
     session.headers['Authorization'] = 'Bearer ' + get_access_token()
     session.headers['Content-Type'] = 'application/json'
   
     csrf_url = f"{base}/api/v1/security/csrf_token/"
     csrf_res = session.get(csrf_url)
     csrf_token = csrf_res.json()['result']
   
     session.headers['Referer']= csrf_url
     session.headers['X-CSRFToken'] = csrf_token
     
     payload_json = json.dumps(payload)
   
     r = session.post(url, data=payload_json)
     return r.json()
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to