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 51 52 53 54 55 56 57 58 59 60 61 62 63
| import html2text
import psycopg2
def get_from_dataset(cmd_sql): conn = None try: params = { 'host': "?????", 'user': "????", 'password': "????", 'dbname': "ttrss", 'port': ??00 } conn = psycopg2.connect(**params) cur = conn.cursor()
print(cmd_sql) cur.execute(cmd_sql)
blob = cur.fetchall() cur.close() except (Exception, psycopg2.DatabaseError) as error: print(error) finally: if conn is not None: conn.close() print("get_from_dataset success") return blob
_s="ref_id,feed_id,last_read,last_marked" cmd_sql="SELECT %s FROM public.ttrss_user_entries Where marked=TRUE AND last_marked BETWEEN '2022-04-01' And '2022-5-01'" % _s
g_content="" for _e in sorted(get_from_dataset(cmd_sql),key=lambda x:x[3]): [ref_id,feed_id,last_read,last_marked] = _e _s="id,title,link,updated,content" cmd_sql="SELECT %s FROM public.ttrss_entries WHERE id = %s" % (_s,ref_id) [id,title,link,updated,content] =get_from_dataset(cmd_sql)[0] g_content += "# [%s](%s)\n"%(title,link) g_content +="pubdata:%s\n"%str(updated) g_content +="markdate:%s\n"%str(last_marked) g_content+=html2text.html2text(content) g_content+="\n\n" D="C:\\Users\\talen\\Desktop\\" with open(D+"cc.md",'w',encoding='utf-8') as f: f.write(g_content)
|