coversion of common_sql to python