Generation

generate functionThu, 06 Apr 2023

Schreibe mir einen Code, womit Daten einer Web API in eine Datenbank eingetragen werden können

import requests import json import sqlite3 def collect_api_data(url): response = requests.get(url) return response.json() def insert_data_into_database(data, cursor): for element in data: cursor.execute('INSERT INTO table VALUES (?,?,?,?)', element) connection = sqlite3.connect('database.db') cursor = connection.cursor() insert_data_into_database(collect_api_data('https://www.google.com/search?client=ubuntu&channel=fs&q=python+string+replace+integer&ie=utf-8&oe=utf-8'), cursor) connection.commit() connection.close()

Questions about programming?Chat with your personal AI assistant