De database vullen

Introductie tot databases in Python

Jason Myers

Co-Author of Essential SQLAlchemy and Software Engineer

Deel 2: de database vullen

  • Laad een CSV-bestand in een waardelijst
values_list = []
for row in csv_reader:
    data = {'state': row[0], 'sex': row[1], 'age': row[2],
            'pop2000': row[3], 'pop2008': row[4]}
    values_list.append(data)
Introductie tot databases in Python

Deel 2: De database vullen

  • Voeg de waardelijst in de tabel census in
from sqlalchemy import insert

stmt = insert(employees)
result_proxy = connection.execute(stmt, values_list) print(result_proxy.rowcount)
2
Introductie tot databases in Python

Laten we oefenen!

Introductie tot databases in Python

Preparing Video For Download...