def _object_to_query(obj):
    values = [(f, '\'%s\'' % f.get_db_prep_save(f.value_from_object(obj))) for f in obj._meta.local_fields]
    q = sql.InsertQuery(obj)
    q.insert_values(values)
    compiler = q.get_compiler('default')
    # Normally, execute sets this, but we don't want to call execute
    setattr(compiler, 'return_id', False)
    stmt, params = compiler.as_sql()
    stmt = stmt % params
    return stmt