•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 392,063 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,251 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 1534 | Replies: 4
![]() |
| |
hi 
I need some help for this script
I have
--------------------
------------------
#and want to print this out of "for record in result:"
#but there is an error in
10x in advance
))

I need some help for this script
I have
--------------------
cursor = conn.cursor()
cursor.execute("select * from playlist limit 5")
result = cursor.fetchall()
# iterate through resultset
playlist_txt = ''
for record in result:
mp3id = record[0]
mp3_title = record[1]
mp3_artist = record[2]
playlist_txt += mp3id + mp3_title + mp3_artist
#print mp3id , " - ", mp3_title , ' - ', mp3_artist , "<br />"
cursor.close()
conn.close()#and want to print this out of "for record in result:"
print playlist_txt
#but there is an error in
playlist_txt += mp3id + mp3_title + mp3_artist
10x in advance
)) •
•
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,394
Reputation:
Rep Power: 9
Solved Threads: 172
Can you give us the error message and a little more of your code?
Without that info, I don't know what your resultset looks like. I can only assume that mp3id could be an integer and needs to be converted to a string to work with the + concatination. In this case mp3id = str(record[0]) would do the trick.
Without that info, I don't know what your resultset looks like. I can only assume that mp3id could be an integer and needs to be converted to a string to work with the + concatination. In this case mp3id = str(record[0]) would do the trick.
May 'the Google' be with you!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
- Problem formating VB string for clipboard (Visual Basic 4 / 5 / 6)
- Addnew problem (Visual Basic 4 / 5 / 6)
- ANSI string problem (C++)
- Problem While Processing A String List (C++)
- Help with problem (Java)
Other Threads in the Python Forum
- Previous Thread: copy a file
- Next Thread: Opening HTTP sessions with Python



Hybrid Mode