From 093ff2d28455899ef53cee74d0b5466ecf0a1eac Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 6 Jun 2018 18:20:41 +0200 Subject: [PATCH 1/2] updated README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index d03d3bd..96085b4 100755 --- a/README.md +++ b/README.md @@ -36,3 +36,13 @@ brew install imagemagick@6 Create a symlink to this newly installed dylib file as mentioned in other answer to get things working. ln -s /usr/local/Cellar/imagemagick@6//lib/libMagickWand-6.Q16.dylib /usr/local/lib/libMagickWand.dylib +## install pyrqlite + +git clone https://github.com/rqlite/pyrqlite.git +pip install ./pyrqlite + +## install sqlalchemy-rqlite + +git clone https://github.com/rqlite/sqlalchemy-rqlite.git +cd sqlalchemy-rqlite +sudo python3 ./setup.py install From 7938ec3591d4339da20da558825fe04138ce77b2 Mon Sep 17 00:00:00 2001 From: Michael Murtaugh Date: Wed, 6 Jun 2018 19:32:40 +0200 Subject: [PATCH 2/2] csv export --- app/views.py | 17 +++++++++++++++++ import_csv.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index ccedbb1..acc2e22 100755 --- a/app/views.py +++ b/app/views.py @@ -394,6 +394,23 @@ def add_to_stack(id): db.session.commit() return render_template('show_stack_detail.html', stack=stack) +from csv import DictWriter +import io + +@app.route('/export/csv', methods=['GET']) +def export_csv (): + output = io.StringIO() + fieldnames = ['title', 'authors'] + csv = DictWriter(output,fieldnames) + csv.writeheader() + # for i in range(10): + # csv.writerow({'ID': i, 'fruit': "Tomato"}) + for book in Book.query.order_by("title"): + authors = ", ".join([x.author_name for x in book.authors]) + csv.writerow({"title": book.title, "authors": authors}) + resp = Response(output.getvalue(), mimetype="text/plain") + # resp.headers["Content-Disposition"] = "attachment;filename=export.csv" + return resp ### # The API ### diff --git a/import_csv.py b/import_csv.py index 9aa06d1..b43447d 100644 --- a/import_csv.py +++ b/import_csv.py @@ -39,7 +39,7 @@ with open(args.csv) as f: if stack: b = db.session.query(Stack).filter_by(stack_name=stack).first() if b == None: - b = Stack(stack_name=stack, stack_description=stack_description) + b = Stack(stack_name=stack, stack_description=None) db.session.add(b) book.stacks.append(b)