How to use SELECT statement to get data from SQlite table using with dictionary values? I have below dictionary values.
Example:
dic = {'ID1': ['Name1', 'Name2'],
       'ID2': ['Name1', 'Name3'],
       'ID3': ['Name2']}

I want to print address of every matched names from above dict values into below format.
Example Output:
['ID1', 'adress1' ,'adress2'],
['ID2', 'adress1' ,'adress3'],
['ID3', 'adress2']

Below is my example code of database table that has &quot;Emp_ID&quot;, &quot;Emp_Name&quot;, &quot;Emp_Address&quot;. The dict values are &quot;Emp_Names&quot;, that should be match emp_Names and get the Adresses in to the list as Example out.
import sqlite3


conn=sqlite3.connect('emp.db')
conn.execute(&quot;&quot;&quot;CREATE TABLE IF NOT EXISTS branch
        (Emp_ID TEXT UNIQUE,
    Emp_Name    TEXT UNIQUE,
    Emp_Address TEXT
    )&quot;&quot;&quot;)

conn.execute(&quot;&quot;&quot;INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) \
    VALUES('Emp1', 'Name1', 'adress1')&quot;&quot;&quot;)

conn.execute(&quot;&quot;&quot;INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) \
    VALUES('Emp2', 'Name2', 'adress2')&quot;&quot;&quot;)

conn.execute(&quot;&quot;&quot;INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) \
    VALUES('Emp3', 'Name3', 'adress3')&quot;&quot;&quot;)

conn.execute(&quot;&quot;&quot;INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) \
    VALUES('Emp4', 'Name4', 'adress4')&quot;&quot;&quot;)

conn.execute(&quot;&quot;&quot;INSERT OR IGNORE INTO branch(Emp_ID, Emp_Name, Emp_Address) \
    VALUES('Emp5', 'Name5', 'adress5')&quot;&quot;&quot;)

conn.commit()
conn.close()

For example 'ID1' (column) should not to be changed.
And 'name1' should take its address and 'name2'should take its address and all matched names should take their addresses. Which statements are useful for my scenario. Is it possible? If possible how to to?
Have you tried implementing row factory? https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.row_factory
More details here: https://xbuba.com/questions/3300464/how-can-i-get-dict-from-sqlite-query