mysql interfaceerror,mysqldb interfaceError

I have a very weird problem with mysqldb (mysql module for python).

I have a file with queries for inserting records in tables. If I call the functions from the file, it works just fine; but when trying to call one of the functions from another file it throws me a

_mysql_exception.InterfaceError: (0, '')

I really don't get what I'm doing wrong here..

I call the function from buildDB.py :

import create

create.newFormat("HD", 0,0,0)

The function newFormat(..) is in create.py (imported) :

from Database import Database

db = Database()

def newFormat(name, width=0, height=0, fps=0):

format_query = "INSERT INTO Format (form_name, form_width, form_height, form_fps) VALUES ('"+name+"',"+str(width)+","+str(height)+","+str(fps)+");"

db.execute(format_query)

And the class Database is the following :

import MySQLdb

from MySQLdb.constants import FIELD_TYPE

class Database():

def __init__(self):

server = "localhost"

login = "seq"

password = "seqmanager"

database = "Sequence"

my_conv = { FIELD_TYPE.LONG: int }

self.conn = MySQLdb.connection(host=server, user=login, passwd=password, db=database, conv=my_conv)

# self.cursor = self.conn.cursor()

def close(self):

self.conn.close()

def execute(self, query):

self.conn.query(query)

(I put only relevant code)

Traceback :

Z:\sequenceManager\mysql>python buildDB.py

D:\ProgramFiles\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWa

rning: the sets module is deprecated

from sets import ImmutableSet

INSERT INTO Format (form_name, form_width, form_height, form_fps) VALUES ('HD',0

,0,0);

Traceback (most recent call last):

File "buildDB.py", line 182, in

create.newFormat("HD")

File "Z:\sequenceManager\mysql\create.py", line 52, in newFormat

db.execute(format_query)

File "Z:\sequenceManager\mysql\Database.py", line 19, in execute

self.conn.query(query)

_mysql_exceptions.InterfaceError: (0, '')

The warning has never been a problem before so I don't think it's related.

解决方案

I got this error when I was trying to use a closed connection.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值