Working on database connections
This commit is contained in:
@@ -6,4 +6,5 @@ db_URI = 'mysql+pymysql://pc:pc@192.168.86.198/Podcast'
|
||||
engine = sql.create_engine(db_URI)
|
||||
con = engine.connect()
|
||||
|
||||
metadata = sql.MetaData()
|
||||
metadata = sql.MetaData()
|
||||
|
||||
|
||||
26
main.py
26
main.py
@@ -1,12 +1,12 @@
|
||||
import opml
|
||||
# import sqlalchemy as db
|
||||
import database.py as db
|
||||
import database as db
|
||||
|
||||
userID = None
|
||||
|
||||
def podcastImport (userID):
|
||||
|
||||
|
||||
podcasts = db.Table('Users', db.metadata, autoload=True, autoload_with=db.engine)
|
||||
print(userID)
|
||||
podcasts = db.sql.Table('Users', db.metadata, autoload=True, autoload_with=db.engine)
|
||||
|
||||
outline = opml.parse("podcast_republic_podcasts.opml")
|
||||
x = len(outline)
|
||||
@@ -15,30 +15,32 @@ def podcastImport (userID):
|
||||
while y < x:
|
||||
title = outline[y].title
|
||||
url = outline[y].xmlUrl
|
||||
artwork = outline[y].py_artwork
|
||||
artwork = outline[y].pr_artwork
|
||||
desc = outline[y].pr_desc
|
||||
query = """insert into """ + podcasts+""""(userID, title, URL, desc, artworkURL values (""" + userID + """,""" + title + """,""" + url + """,""" + desc + """,""" + artwork + """)"""
|
||||
query = """insert into podcasts""""(userID, title, URL, desc, artworkURL values (""" + userID + """,""" + title + """,""" + url + """,""" + desc + """,""" + artwork + """)"""
|
||||
|
||||
# print(str(query))
|
||||
db.con.execute(query)
|
||||
y=y+1
|
||||
|
||||
|
||||
def login():
|
||||
username = 'dan'
|
||||
username = 'Dan'
|
||||
password = 'password'
|
||||
|
||||
|
||||
user = db.Table('Users', db.metadata, autoload=True, autoload_with=db.engine)
|
||||
user = db.sql.Table('Users', db.metadata, autoload=True, autoload_with=db.engine)
|
||||
|
||||
query = db.text(""" select userID from """ + user + """ where username =""" + username)
|
||||
query = db.sql.text(""" select userID from Users where username = \"""" + username+"""\"""")
|
||||
result = db.con.execute(query).fetchone()
|
||||
|
||||
db.con.close()
|
||||
print(result[0])
|
||||
|
||||
return result
|
||||
return result[0]
|
||||
|
||||
|
||||
while True:
|
||||
userID = None
|
||||
print("user " + str(userID))
|
||||
|
||||
print("1. Login \n 2. Upload")
|
||||
val = input(">>>")
|
||||
|
||||
Reference in New Issue
Block a user