Am Mittwoch, 21. November 2012 20:49:14 UTC+1 schrieb Hans Mulder:
> On 21/11/12 18:19:15, Christian wrote:
>
> > Hi ,
>
> >
>
> > my purpose is a generic insert via tuple , because the number of fields
> > and can differ. But I'm stucking .
>
> >
>
> > ilist=['hello',None,7,None,None]
>
On 21/11/12 18:19:15, Christian wrote:
> Hi ,
>
> my purpose is a generic insert via tuple , because the number of fields and
> can differ. But I'm stucking .
>
> ilist=['hello',None,7,None,None]
>
> #This version works, but all varchar fields are in extra '' enclosed.
> con.execute(""" INSER
On Wed, Nov 21, 2012 at 9:19 AM, Christian wrote:
> Hi ,
>
> my purpose is a generic insert via tuple , because the number of fields and
> can differ. But I'm stucking .
>
> ilist=['hello',None,7,None,None]
>
> #This version works, but all varchar fields are in extra '' enclosed.
> con.execute(
Hi ,
my purpose is a generic insert via tuple , because the number of fields and
can differ. But I'm stucking .
ilist=['hello',None,7,None,None]
#This version works, but all varchar fields are in extra '' enclosed.
con.execute(""" INSERT INTO {} VALUES %r; """.format(table) , (tuple(ilist),))
On 14 Jul., 17:31, Billy Mays wrote:
> On 07/14/2011 11:00 AM, Christian wrote:
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > I get some problem when i like to set the table name dynamic.
> > I'm appreciate for any help.
>
> > Christian
>
> > ### works
> > newcur.execute ( """ INSERT INTO events (id1,id2
On 07/14/2011 11:00 AM, Christian wrote:
Hi,
I get some problem when i like to set the table name dynamic.
I'm appreciate for any help.
Christian
### works
newcur.execute ( """ INSERT INTO events (id1,id2) VALUES (%s,%s);
""" , (rs[1],rs[2]))
### works not
newcur.execute ( """ INSE
On Fri, Jul 15, 2011 at 1:00 AM, Christian wrote:
> Hi,
>
> I get some problem when i like to set the table name dynamic.
> I'm appreciate for any help.
>
> ### works but is not really perfect: None from rs list result in
> "None" instead of NULL.
> newcur.execute ( """ INSERT INTO %s_events (id
Hi,
I get some problem when i like to set the table name dynamic.
I'm appreciate for any help.
Christian
### works
newcur.execute ( """ INSERT INTO events (id1,id2) VALUES (%s,%s);
""" , (rs[1],rs[2]))
### works not
newcur.execute ( """ INSERT INTO %s_events (id1,id2) VALUES (%s,
Thanks to all for your time and patience with this!
The insert is working fine based on the suggestions in this thread.
I now have another problem that should be resolved with a regular
expression to remove currency formatting before inserting into the db.
--
http://mail.python.org/mailman/listinf
Thanks for the information.
However I must stick to decimal since I'm dealing with monetary
values.
I loose the decimals with int and float has only supports one decimal
place.
I tried as you suggested to use the %s instead of the %d to no avail.
--
http://mail.python.org/mailman/listinfo/python-l
maestroQC wrote:
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(self, date, accountNumber, description,
openingBalance):
dec = decimal.Decimal(openingBalance)
db = MySQLdb.connec
maestroQC wrote:
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(self, date, accountNumber, description,
openingBalance):
dec = decimal.Decimal(openingBalance)
db = MySQLdb.connec
maestroQC wrote:
cursor.execute("INSERT INTO es_accounts (dateCreated,
accountNumber, description, openingBalance) VALUES (%s, %s, %s
, %d)", (date, accountNumber, description, dec))
File "c:\python25\lib\site-packages\MySQLdb\cursors.py", line 151,
in execute
query = query % db.literal
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(self, date, accountNumber, description,
openingBalance):
dec = decimal.Decimal(openingBalance)
db = MySQLdb.connect(host="localhost",
Hello there,
I was going through the thread of conversation happening around inserting
null using python into mysql.
I am facing a similar problem here. I have to insert say 8 values into a
table using a stored procedure. Of the 8 values 2 are not null and the
remaining can be null, most
erikcw wrote:
> 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()
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()
File "wa.py", line 112, in walkD
I figured this out. Because I am using InnoDB, I need to add the commit
statement. Phew.
Yaron Butterfield wrote:
> Hi,
>
> I've been having problems using Python to insert data into a MySQL
> database. I've donw web searches and pulled my hairs out getting it
> to work but cannot. I have
Hi,
I've been having problems using Python to insert data into a MySQL
database. I've donw web searches and pulled my hairs out getting it to
work but cannot. I have no trouble doing select queries, but when I use
Python to insert, though I do not receive any errors from python, the
table doe
"Steve Holden" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> >
> If you don't understand parameterized SQL queries you would do well to
> refrain from offering database advice :-)
Did the poster ask a question about parameterized queries or server
security?
> Presumably you always
Thanks for the many replies!
The problem was that is use '%s', i have to use %s and then my problem
is solved.
--
http://mail.python.org/mailman/listinfo/python-list
Thomas Bartkus wrote:
[...]
>
> Others here have pointed out that the Python keyword "None" is converted to
> "Null" when passed to MySQL. I don't quite understand this and don't really
> care. If I have a Python variable that has a value None, and I want to
> transmit this to MySQL as Null - I w
"Python_it" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I know how to insert values in a database.
> That's not my problem!
> My problem is how i insert NULL values in de mysql-database.
> None is een object in Python and NULL not.
> None is not converted to NULL?
> Table shows No
Python_it wrote:
> I know how to insert values in a database.
> That's not my problem!
> My problem is how i insert NULL values in de mysql-database.
> None is een object in Python and NULL not.
> None is not converted to NULL?
> Table shows None and not NULL!
None is converted to mysql's NULL and
Python_it wrote:
> I know how to insert values in a database.
> That's not my problem!
> My problem is how i insert NULL values in de mysql-database.
So you *don't* know how to insert values in a database: as Laszlo wrote,
you might be best using parameterized queries.
> None is een object in Py
Python_it wrote:
> I know how to insert values in a database.
> That's not my problem!
> My problem is how i insert NULL values in de mysql-database.
> None is een object in Python and NULL not.
> None is not converted to NULL?
> Table shows None and not NULL!
As Laszlo wrote, "None will be conver
I know how to insert values in a database.
That's not my problem!
My problem is how i insert NULL values in de mysql-database.
None is een object in Python and NULL not.
None is not converted to NULL?
Table shows None and not NULL!
--
http://mail.python.org/mailman/listinfo/python-list
>
> BTW, you did not write which driver are you using.
Oh, you did. Sorry. :-( Import your DB module 'yourmodule' and then
print yourmodule.paramstyle
Description of paramstyle is also in PEP249:
paramstyle
String constant stating the type of parameter marker
Python 2.4
MySQL-python.exe-1.2.0.win32-py2.4.zip
How can I insert a NULL value in a table (MySQL-database).
I can't set a var to NULL? Or is there a other possibility?
My var must be variable string or NULL.
Becaus i have a if statement:
if
cursor.execute(".insert NULL
Python_it wrote:
>Python 2.4
>MySQL-python.exe-1.2.0.win32-py2.4.zip
>
>How can I insert a NULL value in a table (MySQL-database).
>I can't set a var to NULL? Or is there a other possibility?
>My var must be variable string or NULL.
>Becaus i have a if statement:
>if
> cursor.execute("..
30 matches
Mail list logo