Question: I have two List. first list element `Name Age Sex` and second list element `test 10 female`. I want to insert this data into database. In first list having `MySQL Column` and in second `MySQL Column Values`.I'm trying to make this query. `INSERT INTO (LIST1) VALUES (List2)` =>`INSERT INTO table (name,age,sex) values (test,10,female)` Is it possible? thanks

Answer: 
How about this?

```
>>> query = 'INSERT INTO (%s) VALUES (%s)' % (','.join([str(i) for i in list1]),
                                              ','.join([str(i) for i in list2]))
>>> print query
INSERT INTO (name,age,sex) VALUES (test,10,female)

```

The `str` is needed because that way, numbers are allowed to be in the list.

Edit: I feel like you could add some effort into this yourself, but anyway. To add quotes, I'd change it to this:

```
>>> list1 = ['name', 'age', 'sex']
>>> list2 = ['test', 10, 'female']
>>> f = lambda l: ','.join(["'%s'" % str(s) for s in l])
>>> print 'INSERT INTO (%s) VALUES (%s)' % (f(list1), f(list2))
INSERT INTO ('name','age','sex') VALUES ('test','10','female')

```
Try getting this to work using the MySQL gui. Once that works properly, then you can try to get it to work with Python using the SQL statements that worked in MySQL.