How do I connect to the database from a module?
Just execute the query, Drupal takes care of everything else.

If it doesn't work, then that's for another reason.

Also, see Given that db_select is much slower than db_query, why would I want to use it?