Hello,
I have a string:
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`,
`gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s)
that is passed to a MySQL cursor from MySQLdb:
ret = cursor.execute( sql, paras)
paras is:
('flindner', 't****@florian-lindner.de', '/home/flindner/', '/home/
flindner/Mail/test', 1001, 1001, '123')
But that gives me an error:
Traceback (most recent call last):
File "account.py ", line 188, in ?
main()
File "account.py ", line 33, in main
execute(action, account_type, options)
File "account.py ", line 129, in execute
executeSQL(sql, options.usernam e, options.login, options.home,
options.directo ry, options.uid, options.gid, options.passwor d)
File "/home/flindner/common.py", line 29, in executeSQL
ret = cursor.execute( sql, paras)
File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line
148, in execute
query = query % db.literal(args )
TypeError: int argument required
I don't see errors in the format string or some other problem....
What's wrong?
Thanks,
Florian 5 5435
On Oct 19, 7:32 am, Florian Lindner <Florian.Lind.. .@xgm.dewrote:
Hello,
I have a string:
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`,
`gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s)
that is passed to a MySQL cursor from MySQLdb:
ret = cursor.execute( sql, paras)
paras is:
('flindner', 'te...@florian-lindner.de', '/home/flindner/', '/home/
flindner/Mail/test', 1001, 1001, '123')
But that gives me an error:
Traceback (most recent call last):
File "account.py ", line 188, in ?
main()
File "account.py ", line 33, in main
execute(action, account_type, options)
File "account.py ", line 129, in execute
executeSQL(sql, options.usernam e, options.login, options.home,
options.directo ry, options.uid, options.gid, options.passwor d)
File "/home/flindner/common.py", line 29, in executeSQL
ret = cursor.execute( sql, paras)
File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line
148, in execute
query = query % db.literal(args )
TypeError: int argument required
I don't see errors in the format string or some other problem....
What's wrong?
Thanks,
Florian
You should be using '?' for parameter bindings in your sql string not
python format specifiers (you are after all writing sql here not
python).
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`,
`gid`, `password`) VALUES (?, ?, ?, ?, ?, ?, ?)
Cheers
Tim ti******@gmail. com wrote:
On Oct 19, 7:32 am, Florian Lindner <Florian.Lind.. .@xgm.dewrote:
>Hello, I have a string:
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`, `gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s)
that is passed to a MySQL cursor from MySQLdb:
ret = cursor.execute( sql, paras)
paras is:
('flindner', 'te...@florian-lindner.de', '/home/flindner/', '/home/ flindner/Mail/test', 1001, 1001, '123')
But that gives me an error:
Traceback (most recent call last): File "account.py ", line 188, in ? main() File "account.py ", line 33, in main execute(action, account_type, options) File "account.py ", line 129, in execute executeSQL(sql, options.usernam e, options.login, options.home, options.direct ory, options.uid, options.gid, options.passwor d) File "/home/flindner/common.py", line 29, in executeSQL ret = cursor.execute( sql, paras) File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line 148, in execute query = query % db.literal(args ) TypeError: int argument required
I don't see errors in the format string or some other problem....
What's wrong?
You should be using '?' for parameter bindings in your sql string not
python format specifiers (you are after all writing sql here not
python).
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`,
`gid`, `password`) VALUES (?, ?, ?, ?, ?, ?, ?)
Sorry Tim, but that isn't correct:
>>import MySQLdb MySQLdb.param style
'format'
Florian, what happens when you replace your %i with %s?
--
pkm ~ http://paulmcnett.com
On 18 Okt., 22:08, Paul McNett <p...@ulmcnett. comwrote:
timar...@gmail. com wrote:
On Oct 19, 7:32 am, Florian Lindner <Florian.Lind.. .@xgm.dewrote:
Hello,
I have a string:
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`,
`gid`, `password`) VALUES (%s, %s, %s, %s, %i, %i, %s)
that is passed to a MySQL cursor from MySQLdb:
ret = cursor.execute( sql, paras)
paras is:
('flindner', 'te...@florian-lindner.de', '/home/flindner/', '/home/
flindner/Mail/test', 1001, 1001, '123')
But that gives me an error:
Traceback (most recent call last):
File "account.py ", line 188, in ?
main()
File "account.py ", line 33, in main
execute(action, account_type, options)
File "account.py ", line 129, in execute
executeSQL(sql, options.usernam e, options.login, options.home,
options.directo ry, options.uid, options.gid, options.passwor d)
File "/home/flindner/common.py", line 29, in executeSQL
ret = cursor.execute( sql, paras)
File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line
148, in execute
query = query % db.literal(args )
TypeError: int argument required
I don't see errors in the format string or some other problem....
What's wrong?
You should be using '?' for parameter bindings in your sql string not
python format specifiers (you are after all writing sql here not
python).
INSERT INTO mailboxes (`name`, `login`, `home`, `maildir`, `uid`,
`gid`, `password`) VALUES (?, ?, ?, ?, ?, ?, ?)
Sorry Tim, but that isn't correct:
>import MySQLdb MySQLdb.params tyle
'format'
Florian, what happens when you replace your %i with %s?
That works! Thanks! But a weird error message for this solution...
En Fri, 19 Oct 2007 05:32:04 -0300, Dennis Lee Bieber
<wl*****@ix.net com.comescribió :
On Thu, 18 Oct 2007 13:40:53 -0700, Florian Lindner
<Fl************ *@xgm.dedeclaim ed the following in comp.lang.pytho n:
>That works! Thanks! But a weird error message for this solution...
Not really... The MySQLdb adapter converts all parameters to
properly delimited STRINGS (I don't know of any SQL system that passes
/binary/ numerics). But MySQLdb also uses Python % formatting to then
I'd say the opposite: only poorly implemented systems convert numeric
arguments to text.
*Real* bound variables are passed as pointers. The SQL sentence can be
prepared and re-used with different sets of values several times, without
having to re-parse it again and again.
If the MySQLdb adapter actually converts and inserts the arguments itself
into the supplied SQL sentence, generating a new string for each call,
this advantage -and many others- are cancelled, defeating the purpose of
bound variables.
--
Gabriel Genellina
Dennis Lee Bieber wrote:
I should also add that I'm still using a somewhat older MySQLdb (one
reason I haven't upgraded Python to 2.5 series -- finding trusted binary
builds of the third-party stuff is a pain...)
What, you don't trust the build from a World of Warcraft guild?
John Nagle This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fons Dijkstra |
last post by:
Hello,
I'm using the mx.ODBC.Windows package in order to read/write a MSAccess
database. Everything works fine apart from the DATE format handling. I'm
using the default "datetimeformat" (i.e. DATETIME_DATETIMEFORMAT) as
suggested. The date columns in the MSAccess database have "Short Date"
format.
When I read a DATE item everything works fine, like:
|
by: Lad |
last post by:
I have the following
program( only insert a record)
################
import MySQLdb
conn = MySQLdb.connect (host = "localhost",user = "", passwd =
"",db="dilynamobily")
cursor = conn.cursor ()
cursor.execute("""CREATE TABLE produkt1 (
id int(10) unsigned NOT NULL auto_increment,
MyNumber varchar(30) NOT NULL default '',
|
by: yqlu |
last post by:
I hava developed a client in C# that is connected to a 3-party XML Web
Services developed in Java based on the AXIS 1.1. Most methods call are
successful except for one method named "findObjects" and return a complex
type "FieldSearchResult". The error message as following :
"Cannot assign object of type System.String to an object of type
System.String. There is an error in XML document (23, 97)."
By the way,I hava written a client in Java...
|
by: Daniel Crespo |
last post by:
Hi to all,
I'm using adodb for accessing mysql and postgres. My problem relies on
the mysql access.
Sometimes, when I try to execute a query (using ExecTrans method
below), I get this error:
'NoneType' object has no attribute 'cursor'
|
by: cnplnsk |
last post by:
I have mysql server version: 5.0.15
I am facing this problem last a week about cursor.
well ! i have created cursor program as follows...
I written this program as external file, named as c:\sqldata\cur_test.sql
and compiled it using command
mysql> \. c:\sqldata\cur_test.sql
#PROGRAM HERE
drop procedure if exists cur_test;
delimiter $$
| |
by: erikcw |
last post by:
Hi,
I'm trying to insert some data from an XML file into MySQL. However,
while importing one of the files, I got this error:
Traceback (most recent call last):
File "wa.py", line 304, in ?
main()
File "wa.py", line 257, in main
curHandler.walkData()
|
by: krishnakant Mane |
last post by:
hello,
I finally got some code to push a pickled list into a database table.
but now the problem is technically complex although possible to solve.
the problem is that I can nicely pickle and store lists in a blob
field with the help of dumps() for picklling into a string and then
passing the string to the blob.
I am also able to get back the string safely and do a loads() to
unpickle the object.
but this only works when list contains...
|
by: len |
last post by:
Hi All
I have started a little pet project to learn python and MySQL. The
project involves figuring out all the combinations for a 5 number
lottery and storing the data in a MySQL file.
The file looks like this;
+----------+---------------------+------+-----+---------
+----------------+
| Field | Type | Null | Key | Default |
|
by: Edwin.Madari |
last post by:
-----Original Message-----
statement prepared first and executed many times with exectemany - db API http://www.python.org/dev/peps/pep-0249/
inline statemets can be exeucuted only.
hope that helps
Edwin
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |