user1411335
user1411335

Reputation: 3590

Convert python string array for SQL column names

How to convert python array like columns = ['column1', 'column2', 'column3'] for forming SQL statement like

"Select column1, column2, column3 from table" ?

I can use join on array but don't know how to get rid of quotes of string.

Upvotes: 1

Views: 1229

Answers (1)

James K. Lowden
James K. Lowden

Reputation: 7837

>>> 'select ' + ', '.join([c for c in columns]) + ' from table'
'select column1, column2, column3 from table'

Is that what you have in mind?

Upvotes: 2

Related Questions