0

first sorry for my bad english. i'm php programmer and I just started a python programming language.

Mysql code:

SELECT * FROM `datapy` ORDER BY `No` DESC LIMIT 0,1

And show row:

++++++++++++++++++
++ NO +++ nilai ++
++++++++++++++++++
++ 12 +++  100  ++
++++++++++++++++++

in php it's very easy for select column and save as variable using:

$row = $takecolumn['nilai'];

What should I do if in python using mysqldb?

1 Answer 1

1

you can create a database object like db and use cursor()

cur=db.cursor()
cur.execute("select nilai from datapy ORDER BY `No` DESC LIMIT 0,1")
rows = cur.fetchall()
Sign up to request clarification or add additional context in comments.

7 Comments

whether it would only take the "value"? or take entirely?
it's store whole query result in rows you can fetch all value ..use loop.....sorry for my bad english @Eightleven
so, i want take "nilai" column and the script is rows = cur.fetchall(nilai) ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.