Varia library working group XPPL. https://gitea.xpub.nl/XPUB/XPPL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
727 B

#import click
#from flask import Flask
from app import app, db
from app.models import Book
from csv import DictReader
import argparse
ap = argparse.ArgumentParser("import csv into flask")
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()
7 years ago
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__)
7 years ago
#books = db.session.query(Book).all()
#print(books)
# @app.cli.command()
# @click.argument('name')
# def import_csv(name):
# print("hello")