MySQLdb Help

Venkat Addala venkat.boffin at gmail.com
Tue Sep 17 03:13:20 EDT 2013


Hi all,


  I'm new to python, i am connecting mysql database with python. now i want
to do sanitation on the database, like to remove "\n", extra spaces blah
blah.. and update it back to mysql database. i was trying somthing, here is
my code, can you please provide me solution for this..

#!/usr/bin/python
import MySQLdb as mdb

con = mdb.connect('localhost', 'root', 'pass at 123', 'workbench');

with con:
  cur = con.cursor()
  cur.execute("SELECT descrip FROM table LIMIT 1")
  rows = cur.fetchall()
  for row in rows:
    row_new = row[0].split("\n", " ")
    row = "".join(row_new)
  print row
exit(0)
--

Regards
Boffin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130917/5adeeeba/attachment.html>


More information about the Python-list mailing list