From b349a656db02bc02b8bb0feb94cb356d0f0435aa Mon Sep 17 00:00:00 2001 From: Andrew Doroschenko Date: Mon, 8 Feb 2016 12:18:36 +0300 Subject: [PATCH] Enabled compliance test file in DataBase.query_file() When requesting the file is not checked, this directory or file. It should do library --- records.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/records.py b/records.py index 807784f..5f4a2e3 100644 --- a/records.py +++ b/records.py @@ -122,6 +122,15 @@ class Database(object): def query_file(self, path, params=None, fetchall=False): """Like Database.query, but takes a filename to load a query from.""" + + # If path doesn't exists + if not os.path.exists(path): + raise FileNotFoundError + + # If it's a directory + if os.path.isdir(path): + raise IsADirectoryError + # Read the given .sql file into memory. with open(path) as f: query = f.read()