Hi,
Its one of those days. I cannot solve this. Any help would be greatly
appreciated!
When I execute this:
class Db(object):
def insertAccount(s elf, date, accountNumber, description,
openingBalance) :
dec = decimal.Decimal (openingBalance )
db = MySQLdb.connect (host="localhos t", user="dumb",
passwd="dumber" , db="rdc")
cursor = db.cursor()
cursor.execute( "INSERT INTO es_accounts (dateCreated,
accountNumber, description, openingBalance) VALUES (%s, %s, %s, %d)",
(date, accountNumber, description, dec))
I get this error:
Traceback (most recent call last):
File "main.py", line 59, in <module>
main()
File "main.py", line 40, in main
dbObj.insertAcc ount(dateTo, item[0], item[1], item[8])
File "C:\projects\wo rkspace\INYR_ES _0.1\src\db.py" , line 19, in
insertAccount
cursor.execute( "INSERT INTO es_accounts (dateCreated,
accountNumber, description, openingBalance) VALUES (%s, %s, %s
, %d)", (date, accountNumber, description, dec))
File "c:\python25\li b\site-packages\MySQLd b\cursors.py", line 151,
in execute
query = query % db.literal(args )
TypeError: int argument required
My table is defined as:
CREATE TABLE es_accounts (
id int(6) not null auto_increment,
dateCreated date DEFAULT '0000-00-00',
accountNumber int(6) not null,
description varchar(255) not null,
openingBalance decimal(15,8) NOT NULL DEFAULT 0.00000000,
primary key (id)
);
TIA
Its one of those days. I cannot solve this. Any help would be greatly
appreciated!
When I execute this:
class Db(object):
def insertAccount(s elf, date, accountNumber, description,
openingBalance) :
dec = decimal.Decimal (openingBalance )
db = MySQLdb.connect (host="localhos t", user="dumb",
passwd="dumber" , db="rdc")
cursor = db.cursor()
cursor.execute( "INSERT INTO es_accounts (dateCreated,
accountNumber, description, openingBalance) VALUES (%s, %s, %s, %d)",
(date, accountNumber, description, dec))
I get this error:
Traceback (most recent call last):
File "main.py", line 59, in <module>
main()
File "main.py", line 40, in main
dbObj.insertAcc ount(dateTo, item[0], item[1], item[8])
File "C:\projects\wo rkspace\INYR_ES _0.1\src\db.py" , line 19, in
insertAccount
cursor.execute( "INSERT INTO es_accounts (dateCreated,
accountNumber, description, openingBalance) VALUES (%s, %s, %s
, %d)", (date, accountNumber, description, dec))
File "c:\python25\li b\site-packages\MySQLd b\cursors.py", line 151,
in execute
query = query % db.literal(args )
TypeError: int argument required
My table is defined as:
CREATE TABLE es_accounts (
id int(6) not null auto_increment,
dateCreated date DEFAULT '0000-00-00',
accountNumber int(6) not null,
description varchar(255) not null,
openingBalance decimal(15,8) NOT NULL DEFAULT 0.00000000,
primary key (id)
);
TIA
Comment