SQL Query output formatting URL in python
<p>I am new to python. I am writing a script which queries the database for a URL string. Below is my snippet.</p>

<pre><code>db.execute('select sitevideobaseurl,videositestring '
          'from site, video '
          'where siteID =1 and site.SiteID=video.VideoSiteID limit 1')
result = db.fetchall()

for row in result:
  videosite= row[0:2]
  print videosite
</code></pre>

<p>It gives me baseURL from a table and the video site string from another table.
output: <code>('http://www.youtube.com/watch?v={0}', 'uqcSJR_7fOc')</code></p>

<p>I wish to format the output by removing the braces, quotes and commas and replace the {0} from baseURL with sitestring: uqcSJR_7fOc. 
something like: <a href="https://www.youtube.com/watch?v=uqcSJR_7fOc" rel="nofollow">https://www.youtube.com/watch?v=uqcSJR_7fOc</a> in the final output and wish to write this to a file. </p>

<p>Thanks for your time and help in advance.</p>

<p>Use <a href="https://docs.python.org/2/library/stdtypes.html#str.format" rel="nofollow"><code>str.format</code></a>.</p>

<pre><code>db.execute('select sitevideobaseurl,videositestring '
          'from site, video '
          'where siteID =1 and site.SiteID=video.VideoSiteID limit 1')
result = db.fetchall()

for row in result:
  videosite= row[0:2]
  print videosite[0].format(videosite[1])
</code></pre>

python sql url formatting