import mysql.connector as sql import pandas as pd import re yhendus=sql.connect(host='localhost', database='mart', user='mart', password='ajutine1234') df=pd.read_sql("""SELECT film_id, production_year, COUNT(*) from efis_film_music JOIN efis_film ON efis_film_music.film_id = efis_film.id GROUP BY film_id; """, yhendus) df.to_csv("filmimuusika.txt")