python 查询mysql,报错

张芳平 发布于 2015/11/19 13:43
阅读 613
收藏 0

开源软件供应链点亮计划,等你来!>>>

python 查询mysql报错

Traceback (most recent call last):
  File "D:/Python27/a.py", line 16, in <module>
    cursor.execute('SELECT  1 FROM TB_AREA')
  File "c:\users\zhangfp\appdata\local\temp\easy_install-opvywq\MySQL_python-1.2.5-py2.7-win32.egg.tmp\MySQLdb\cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "c:\users\zhangfp\appdata\local\temp\easy_install-opvywq\MySQL_python-1.2.5-py2.7-win32.egg.tmp\MySQLdb\connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1046, 'No database selected')

源码是:

#mysqldb      
import  MySQLdb   
          
#connect   
conn=MySQLdb.connect(host="localhost",user="root",passwd="123456")    
cursor = conn.cursor()      
          
cursor.execute('SELECT  1 FROM TB_AREA')
conn.close()  
加载中
0
Beyond-Bit
Beyond-Bit
该评论暂时无法显示,详情咨询 QQ 群:912889742
0
H
Handsome2734
该评论暂时无法显示,详情咨询 QQ 群:912889742
张芳平
张芳平
该评论暂时无法显示,详情咨询 QQ 群:912889742
张芳平
张芳平
该评论暂时无法显示,详情咨询 QQ 群:912889742
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部