1

I am working on making a API call and saving the data and storing it to MySQL database using Python.

Below is a portion of my code:

async def main():
    user = input("Enter username: ")
    pwd = getpass.getpass()
    session_header = {
        "Accept":     "application/json",
        "Content-Type": "application/json",
    }         
    with Bar(
        "Generating",
        max=(len(APIs.keys()) *   5),
        suffix="%(percent)d%%",
    ) as progress_bar:
        for instance in     APIs.keys():
            async with    httpx.AsyncClient(                    
            verify=False,
            auth=(user, pwd),
            headers=session_header,
            timeout=None,
            ) as async_session:
            progress_bar.next()
            state = await get_instance_state(instance, async_session)
            progress_bar.next()
            data = await get_vm_data(instance, state, async_session)
            progress_bar.next()
        table = create_table(data)
        print (table); 
        #I am getting data(df) till here
if __name__ == "__main__":
    asyncio.run(main())

Now I want to create a list from above (table = create_table(data) here: (Please help how to do this)

MyList = []

then want to use sql.connector to connect to database and INSERT those data data to MySQL database (Please help how to do this)

I get the values from API, and able to print the data. Now I need help storing them to MySQL database.

Now I want to insert that data to MySQL database.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.