0

As I know, the SELECT syntax is used for getting data from a row instead of column, here I have a column called time in a table, and I just want to select all the data in this time column, put them in an array, and use this array later.

So how can I select a column of data and put them into an array?

Michael J. Barber
25.2k9 gold badges71 silver badges92 bronze badges
asked Nov 24, 2011 at 10:02

1 Answer 1

2

The query: SELECT time FROM Table

Use this query to populate an array in python!

db = MySQLdb.connect(user="yourUser",passwd="1337",db="awesomeDB")
cursor = db.cursor()
resultSet = "SELECT time FROM tableX"
cursor.execute(resultSet)
for row in cursor
#do something here, maybe add to an array if you want
arrayList.append(row)

Something like this?

answered Nov 24, 2011 at 10:06
Sign up to request clarification or add additional context in comments.

1 Comment

me too. If it was helpful, please upvote and mark as answer as it gives incentive to users to answer questions :)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.