From 755e7c5ce45b85b278dcc1d497a18336fb2af3ac Mon Sep 17 00:00:00 2001 From: Lulzette Date: Mon, 27 Sep 2021 02:19:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B0=20=D1=81=D1=83=D1=89=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=91=D0=94/?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.py b/main.py index 2d1c917..24d21c8 100755 --- a/main.py +++ b/main.py @@ -5,6 +5,7 @@ import pymongo # TODO: auth to /admin # TODO: timestamps to posts # TODO: author to posts and multiple users +# TODO: add bottle's params to config class Config: @@ -23,9 +24,13 @@ class Config: self.readConfig() mongoclient = pymongo.MongoClient(self.host, self.port) + if self.dbname not in mongoclient.list_database_names(): + print('DB not found, creating') database = mongoclient[self.dbname] # TODO: Create table if not exists + if 'posts' not in database.list_collection_names(): + print('Table not fount, creating') posts = database['posts'] self.posts = posts