Added some basic logic to import OPML files into database. Broke some sql server settings into separate file.

This commit is contained in:
Dan Dembinski
2020-02-19 16:02:34 -05:00
parent 176984051d
commit d9d9a1ffdf
2 changed files with 52 additions and 6 deletions

49
main.py
View File

@@ -1,14 +1,51 @@
import opml
# import sqlalchemy as db
import database.py as db
def podcastImport (userID):
podcasts = db.Table('Users', db.metadata, autoload=True, autoload_with=db.engine)
def podcastImport ():
outline = opml.parse("podcast_republic_podcasts.opml")
x = len(outline)
y=0
while y < x:
print(outline[y].title)
print(outline[y].xmlUrl)
print(outline[y].pr_artwork)
print(outline[y].pr_desc)
print()
title = outline[y].title
url = outline[y].xmlUrl
artwork = outline[y].py_artwork
desc = outline[y].pr_desc
query = """insert into """ + podcasts+""""(userID, title, URL, desc, artworkURL values (""" + userID + """,""" + title + """,""" + url + """,""" + desc + """,""" + artwork + """)"""
db.con.execute(query)
y=y+1
def login():
username = 'dan'
password = 'password'
user = db.Table('Users', db.metadata, autoload=True, autoload_with=db.engine)
query = db.text(""" select userID from """ + user + """ where username =""" + username)
result = db.con.execute(query).fetchone()
db.con.close()
return result
while True:
userID = None
print("1. Login \n 2. Upload")
val = input(">>>")
if val == "1":
userID = login()
elif val == "2":
if userID is None or userID == '':
print("Please login first")
else:
podcastImport(userID)