How do I read echo data into my program

I am using Python & the Request Module to retrieve data from server... the server is returning mysql querry data ... it's not much data so I am simply echoing the data

echo back data
AGE : 18
GENDER : Male 

Open in new window

I'm using this code to read the echo back data
import requests
r = requests.get('')
data = r.text
print data

Open in new window

it prints
LAST NAME : Elmer <br> FIRST NAME : Fudd <br> AGE : 18 <br> GENDER : Male <br>

this is  a Noob question ... how would I handle inserting this data in my database in my app... I ask because I have tried to assign an echo value from r.text method and nothing happens I also tried the r.content method and nothing ...

for rows in cursor:
		Last_Name = rows[2]
		First_Name = rows[3]
		AGE= rows[4]
		GENDER = rows[5]

con = lite.connect('msf/xxxx.sqlite')
		con.text_factory = str
		cur = con.cursor()
		cur.execute('insert or replace into ptrecords values(?,?,?,?)',
		    ( Last_Name, First_Name, Age,Gender))

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do you have control over the FetchData.php script?
If yes, then you could simplyfy your work a little.
if you have a php json library, then I'd print out the text as json string or print out without <br> and just '\n' and make sure, that any potential '\n' in the value field is escaped..

If not, then:
Can you be sure, 'that the string "<br>" will never be part of the database?

If yes, then this might work (code untested):
rows = data.split('<br>')[:-1]

# next line might work if you know, that the order of your echo is always predictable 
# and if it's identical to the order in your sqlitedb

values = [ row.split(':')[1].strip()  for row in rows ]
cur.execute('insert or replace into ptrecords values(?,?,?,?)',
		    ( Last_Name, First_Name, Age,Gender))

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dolamitejenkinsAuthor Commented:
Perfect thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.