aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-01-11 23:41:00 +0100
committerneodarz <neodarz@neodarz.net>2019-01-11 23:41:00 +0100
commitc01eb0e3220924c24aabc3ccd282f89f9ed9cb3e (patch)
tree923bfd3ac6d42a182641f3e67ac9454b32e0ba22
parent82746a2b76e5948333133bfe07c1042af2cd33b7 (diff)
downloadkhanindexer-c01eb0e3220924c24aabc3ccd282f89f9ed9cb3e.tar.xz
khanindexer-c01eb0e3220924c24aabc3ccd282f89f9ed9cb3e.zip
Add first implementation of a database
-rw-r--r--app.py8
-rw-r--r--config.py5
-rw-r--r--database/__init__.py0
-rw-r--r--database/models.py17
-rw-r--r--spider.dbbin0 -> 8192 bytes
5 files changed, 30 insertions, 0 deletions
diff --git a/app.py b/app.py
new file mode 100644
index 0000000..2a80507
--- /dev/null
+++ b/app.py
@@ -0,0 +1,8 @@
+from database.models import Page, db
+import config
+
+def main():
+ db.create_tables([Page])
+
+if __name__ == '__main__':
+ main()
diff --git a/config.py b/config.py
new file mode 100644
index 0000000..3717715
--- /dev/null
+++ b/config.py
@@ -0,0 +1,5 @@
+from os import path
+
+APP_DIR = path.dirname(__file__)
+
+DATABASE = '%s' % path.join(APP_DIR, 'spider.db')
diff --git a/database/__init__.py b/database/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/database/__init__.py
diff --git a/database/models.py b/database/models.py
new file mode 100644
index 0000000..4b27806
--- /dev/null
+++ b/database/models.py
@@ -0,0 +1,17 @@
+from peewee import Model, CharField, SqliteDatabase
+
+import config
+
+db = SqliteDatabase(config.DATABASE)
+db.connect()
+
+class Page(Model):
+ """
+ Page of a website
+ """
+ url = CharField()
+ title = CharField()
+ content = CharField()
+
+ class Meta:
+ database = db
diff --git a/spider.db b/spider.db
new file mode 100644
index 0000000..7e60fa8
--- /dev/null
+++ b/spider.db
Binary files differ