I have been searching for a while and I have not found a good enough method to extract the tables and columns. My final intention is to have all the columns used in format table.column. I use python. I have tried python libraries like sql_metadata, but it is not as precise as I would like. I tried Parser(query).tables and Parser(query).columns I also have the .sqlite (I am using SQLite) databases if it is needed to execute sql. For example: SELECT student_id FROM student_course_attendance WHERE course_id = 301 ORDER BY date_of_attendance DESC LIMIT 1 student_course_attendance.student_id, student_course_attendance.course_id and student_course_attendance.date_of_attendance And I also want to take into account that if for example I do SELECT(*) I will have to get all the attributes. Continue reading...