Skip to content

Instantly share code, notes, and snippets.

@yono
Created February 5, 2010 07:47
Show Gist options
  • Save yono/295616 to your computer and use it in GitHub Desktop.
Save yono/295616 to your computer and use it in GitHub Desktop.
DB中のURLをTeXのリスト形式にして出力
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import MySQLdb
con = MySQLdb.connect(db='webpage_test',user='',passwd='',
use_unicode=True,charset='utf8')
cur = con.cursor()
first = int(sys.argv[1])
num = int(sys.argv[2])
cur.execute('select url from webpage_test limit %d,%d' % (first,num))
rows = cur.fetchall()
for row in rows:
url = row[0].replace('&',r'\&').replace('%',r'\%').replace('_',r'\_')
print r'\item',url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment