From ef76a5c4baede6d1adeb9c9b4d88318f54c6fa85 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 23 May 2018 17:03:47 +0200 Subject: [PATCH] changed import --- import_csv.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/import_csv.py b/import_csv.py index f40102b..6a7e89d 100644 --- a/import_csv.py +++ b/import_csv.py @@ -10,10 +10,16 @@ ap.add_argument("csv", help = "csv file to import") ap.add_argument("--limit", type=int, default = None, help = "limit to x number of x") args = ap.parse_args() -print(args) +with open(args.csv) as f: + for row in DictReader(f): + #print(row['Title']) + book = Book (row['Title'], "", "", row['Format'], row['Shelf']) + db.session.add(book) +db.session.commit() + #app = Flask(__name__) -books = db.session.query(Book).all() +#books = db.session.query(Book).all() #print(books) # @app.cli.command()