Debugging to_sql problem
Fix prepared query