How to connect and insert data in database of wordpress?

Two things, at least: It looks like you need to declare the global $wpdb and you’re using $wpdb->insert() incorrectly. The insert() method doesn’t take your SQL query but a list of variables. It then create the SQL for you. See here

You can execute SQL directly but it’s a different process.