-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.py
50 lines (39 loc) · 1.13 KB
/
init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python3
# SPDX-License-Identifier: MIT
import configparser
import sqlite3
import sys
conn = sqlite3.connect('feeds.db')
c = conn.cursor()
c.execute('''CREATE TABLE settings
(name text,
url text)
''')
c.execute('''CREATE TABLE feeds
(id integer primary key autoincrement,
name text,
title text,
blog_url text,
url text,
etag text,
modified text)
''')
c.execute('''CREATE TABLE posts
(id integer primary key autoincrement,
feed_id integer,
author text,
title text,
post text,
url text,
published_date datetime)
''')
if len(sys.argv) > 1:
config = configparser.ConfigParser()
config.read(sys.argv[1])
for section in config.sections():
if section == 'Planet':
continue
print(f"{section} {config[section]['name']}")
c.execute(f'''INSERT INTO feeds (name, url) VALUES
("{config[section]['name']}", "{section}")''')
conn.commit()