title: Save single Json file data to 2 different table in same SQL DB
body: <p>I need to save json file data onto mysql db. Currently mysql db mydb with table1 and table2. Need to save some part of data json file to table1 and some to table2. Each table1 and table2 have been created.</p>
  
  <p>Below is sample of json data file</p>
  
  <pre><code>{
    "response": {
      "dev_log": {
        "data": [
          {
            "id": "1",
            "timestamp": "2020-01-16 10:11:12",
            "email": "johnd@gmail.com"
          },
          {
            "id": "2",
            "timestamp": "2020-02-27 15:33:34",
            "email": "zack@gmail.com"
          },
          {
            "id": "3",
            "timestamp": "2020-02-27 15:34:07",
            "email": "edy@yahoo.com"
          }
        ],
        "total_dev_log": "1423"
      },
      "client_log": {
        "data": [
          {
            "customer_city": "LONDON",
            "customer_login": "AAAAAAAAAAAAAA",
            "customer_state": "MC",
            "details": "aaaaaaaaaaa-bbbbbbbbbbbbbbb-cccccccccccccc ",
            "log_number": "1",
            "dept": "Sales",
            "staff_id": "S123",
            "staff_name": "EricY",
            "timestamp": "2020-02-27 15:57:24"
          },
          {
            "customer_city": "SINGAPORE",
            "customer_login": "BBBBBBBBBBBBB",
            "customer_state": "XX",
            "details": "ddddddddd-eeeeeeeeeeee-ffffffffffff ",
            "log_number": "1",
            "dept": "Eng",
            "staff_id": "S456",
            "staff_name": "YongG",
            "timestamp": "2020-02-27 15:57:24"
          }
        ],
        "total_hero_query": "13"
      },
      "response_time": "0.723494",
      "transaction_id": "909122",
      "transaction_status": "OK",
      "transaction_time": "Fri Feb 28 15:27:51 2020"
    }
  }
  </code></pre>
  
  <p>Here... in json we have 'dev_log' and 'client_log'.
  Thus..all the values of dev_log should be save onto table1 and client_log onto table2 of mydb databse. </p>
  
  <p>The drafted code below</p>
  
  <pre><code>import pymysql
  import os
  import json
  #import ast
  
  #Read Json string file
  with open('datfile.json', 'r') as f:
     datDict = json.load(f)
  
  #connect to MySQL
  con = pymysql.connect(host = 'localhost',user = 'root',passwd = 'root',db = 'mydb')
  cursor = con.cursor()
  
  #Parse data to SQL insert
  #for i, item in enumerate(datDict):
      #id = ("id", None)
      #timestamp = ("timestamp", None)
      #email = ("email", None)
  
      #cursor.execute("INSERT INTO mytable (id,   timestamp,   email) VALUES (%s,    %s,     %s)", (id,  timestamp,   email))
  cursor.executemany("""INSERT INTO table1 VALUES(id, timestamp, email)""", datDict['response']['dev_log']['data'])
  con.commit()
  con.close()
  </code></pre>
  
  <p>I'm not sure how to save file to sql and some more to 2 different tables. As for now.. i can run the code without any error but return null value as below;</p>
  
  <pre><code>mysql&gt; SELECT * FROM table1;
  +------+-----------+-------+
  | id   | timestamp | email |
  +------+-----------+-------+
  | NULL | NULL      | NULL  |
  | NULL | NULL      | NULL  |
  | NULL | NULL      | NULL  |
  +------+-----------+-------+
  3 rows in set (0.00 sec)
  </code></pre>
  
  <p>mydb database and table table1 have been created.</p>
  
  <p>I really appreciate your help and advise how I can execute further.</p>
  
  <p>Thank you to all</p>