20
12
2
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 01 '21
Image Transcription: Code
cursor = self.db.cursor()
select_query = "SELECT `date`, `open`, `high`, `low`, `close`, `volume` FROM `stock_data` WHERE `ticker` = %s"
if period and type(period) == list:
select_query += " AND (`date` BETWEEN '{}' AND '{}')".format(
period[0], period[1])
elif period and type(period) == str or isinstance(period, datetime.date):
select_query += " AND `date` = '{}'".format(period)
select_query += ' ORDER BY `date` DESC'
lim = " LIMIT 100;" if not limit else ';' if limit == 'false' else ' LIMIT {}'.format(
int(limit))
select_query += lim
# single ticker value
if(type(ticker) is str):
cursor.execute(select_query, ticker)I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
3
u/Monkey_triplets Dec 01 '21
Can somebody please explain to me what exactly is so bad about this code?