longbox

comic book stash manager
git clone git://git.pyratebeard.net/longbox.git
Log | Files | Refs | README

commit cac57944d6dbe84601066b79ba0f0cfd98d1f2cd
parent 3c4d03717686c859e14a3cc60d388f840ea985a5
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 28 Jul 2022 12:48:44 +0100

search db for {series,issue number,date} and output with variant names and barcode (for easy id'ing)

Diffstat:
Mlongbox | 30+++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/longbox b/longbox @@ -9,8 +9,6 @@ # repo ░ https://git.pyratebeard.net/longbox # # TODO -# * read from gcd database -# * search? # * create personal stash database # * add issues from gcd to stash # * easy view stash @@ -19,14 +17,28 @@ from getpass import getpass from mysql.connector import connect, Error +import argparse -search_issue = """ -SELECT gcd_issue.id,gcd_series.name,gcd_issue.number +# parse arguments +parser = argparse.ArgumentParser(description = "comic book stash manager") +parser.add_argument("-s", "--series", help = "search for series title", required = False) +parser.add_argument("-n", "--number", help = "search for issue number", required = False, default = '%') +parser.add_argument("-c", "--current", help = "search for current series", required = False, default = 0) +parser.add_argument("-d", "--date", help = "search for date (use '%' as wildcard, e.g. 'aug%2022')", required = False, default = '%') +argument = parser.parse_args() + +search_series = argument.series +search_number = argument.number +search_current = argument.current +search_date = argument.date + +search_terms = """ +SELECT gcd_issue.id,gcd_series.name,gcd_issue.number,gcd_issue.variant_name,gcd_issue.publication_date,right(gcd_issue.barcode, 5) FROM gcd_series JOIN gcd_issue -WHERE gcd_series.name LIKE "%spider-man%" -AND gcd_series.is_current = 1 -AND gcd_series.last_issue_id = gcd_issue.id -AND gcd_issue.number = 5 +WHERE gcd_series.name LIKE CONCAT('%', %s, '%') +AND gcd_issue.number LIKE CONCAT(%s, '%') +AND gcd_issue.series_id = gcd_series.id +AND gcd_issue.publication_date LIKE CONCAT('%', %s) """ try: @@ -37,7 +49,7 @@ try: database="gcd" ) as connection: with connection.cursor() as cursor: - cursor.execute(search_issue) + cursor.execute(search_terms, (search_series, search_number, search_date,)) for issue in cursor.fetchall(): print(issue) except Error as e: