以下是我目前掌握的代码:from ConfigParser import *
import MySQLdb
configuration = ConfigParser()
configuration.read('someconfigfile.conf')
db = MySQLdb.connect(
host = configuration.get('DATABASE', 'MYSQL_HOST'),
user = configuration.get('DATABASE', 'MYSQL_USER'),
passwd = configuration.get('DATABASE', 'MYSQL_PASS'),
db = configuration.get('DATABASE', 'MYSQL_DB'),
port = configuration.getint('DATABASE', 'MYSQL_PORT'),
ssl = {
'ca': configuration.get('SSL_SETTINGS', 'SSL_CA'),
'cert': configuration.get('SSL_SETTINGS', 'SSL_CERT'),
'key': configuration.get('SSL_SETTINGS', 'SSL_KEY')
},
)
cursor = db.cursor()
sql = "SELECT column_name FROM information_schema.columns WHERE table_name='met';"
cursor.execute(sql)
list = cursor.fetchall()
print list
这是打印的:
^{pr2}$
我得到的是元组而不是列表。我想要一个字符串列表