Re: mysql insert with tuple

2012-11-22 Thread Christian
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] >

Re: mysql insert with tuple

2012-11-21 Thread 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] > > #This version works, but all varchar fields are in extra '' enclosed. > con.execute(""" INSER

Re: mysql insert with tuple

2012-11-21 Thread Chris Rebert
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(

mysql insert with tuple

2012-11-21 Thread Christian
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),))

Re: String formatting - mysql insert

2011-07-14 Thread Christian
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

Re: String formatting - mysql insert

2011-07-14 Thread Billy Mays
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

Re: String formatting - mysql insert

2011-07-14 Thread Chris Angelico
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

String formatting - mysql insert

2011-07-14 Thread Christian
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,

Re: MySQL Insert

2008-07-16 Thread maestroQC
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

Re: MySQL Insert

2008-07-15 Thread maestroQC
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

Re: MySQL Insert

2008-07-15 Thread Ethan Furman
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

Re: MySQL Insert

2008-07-15 Thread Ethan Furman
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

Re: MySQL Insert

2008-07-15 Thread Carsten Haese
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

MySQL Insert

2008-07-15 Thread maestroQC
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",

Python, Mysql, insert NULL

2008-04-04 Thread Pallavi Kale
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

Re: MySQL Insert Unicode Problem

2007-04-09 Thread John Nagle
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()

MySQL Insert Unicode Problem

2007-04-09 Thread erikcw
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

Re: Python, Mysql, insert NULL

2006-05-18 Thread Yaron Butterfield
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

Python, Mysql, insert NULL

2006-05-18 Thread Yaron Butterfield
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

Re: Python, Mysql, insert NULL

2005-10-06 Thread Thomas Bartkus
"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

Re: Python, Mysql, insert NULL

2005-10-06 Thread Python_it
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

Re: Python, Mysql, insert NULL

2005-10-06 Thread Steve Holden
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

Re: Python, Mysql, insert NULL

2005-10-05 Thread Thomas Bartkus
"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

Re: Python, Mysql, insert NULL

2005-10-05 Thread deelan
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

Re: Python, Mysql, insert NULL

2005-10-05 Thread Steve Holden
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

Re: Python, Mysql, insert NULL

2005-10-05 Thread Gerhard Häring
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

Re: Python, Mysql, insert NULL

2005-10-05 Thread Python_it
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

Re: Python, Mysql, insert NULL

2005-10-05 Thread Laszlo Zsolt Nagy
> > 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, Mysql, insert NULL

2005-10-05 Thread Python_it
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

Re: Python, Mysql, insert NULL

2005-10-05 Thread Laszlo Zsolt Nagy
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("..