我在搜索Google时花了好几个小时试图解决这个问题,但我什么也没做。
我正在尝试做一些相对简单的事情;当用户点击图像时,应该出现一个模态,其中包含该图像。
但是,图像不会显示。我可以访问页面其他部分的{{$ctrl.selectedPhoto.photoname}}
,但不能访问ng-template中的import psycopg2
import random
import MySQLdb
from contextlib import closing
conn = psycopg2.connect("dbname='musicbrainz' user='musicbrainz' host='localhost' password='musicbrainz'")
conn1 = MySQLdb.connect(host = "localhost", user = "root", passwd = "40OZlike", db = "plalyst")
print("connections and cursors made...")
cur= conn1.cursor()
conn1.set_character_set('utf8')
cur.execute('SET NAMES utf8;')
cur.execute('SET CHARACTER SET utf8;')
cur.execute('SET character_set_connection=utf8;')
cur.close()
def migrateSongDB():
try:
cur1 = conn1.cursor()
cur1.execute("select count(*) from Song")
numberOfSongs = cur1.fetchall()[0][0]
cur1.close()
print("number of songs in our database is ")
print(numberOfSongs)
rnumbers = random.sample(range(1, 22660511), 100000-numberOfSongs)
print("random numbers generated....")
for eachnum in rnumbers:
cur = conn.cursor()
cur1 = conn1.cursor()
print(eachnum)
songName=""
while(songName==""):
cur.execute("""select name from track where id = %s """, (eachnum,))
rows = cur.fetchall()
print(rows)
if not len(rows)==0:
songName = rows[0][0]
eachnum+=1
print("Got the track name:")
print(songName)
sql = 'INSERT into Song (name) values ( "'+songName+'")'
print(sql)
cur1.execute(sql)
cur1.execute('commit')
print("inserted into the song table....")
cur.close()
cur1.close()
print("Songs Saved into new Data Base...")
conn.close()
conn1.close()
print("Connections Closed")
except:
with conn1 as cursor:
cursor.execute('select 1;')
result = cursor.fetchall()
for cur in result:
print(cur)
migrateSongDB()
def main():
migrateSongDB()
conn.close()
conn1.close()
if __name__ == "__main__": main()
。这是一个关于plunker的链接:https://plnkr.co/edit/3IoK56UdFD5WXDEpAgRb?p=preview
提前感谢您的帮助!