MySQLdb Help

V

Venkat Addala

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@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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top