Manually removing database records of a module I inherited a Drupal 7 site that appears to have a history.

I'm receiving the following error when updating modules or clearing the cache:


  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'website_staging.search_api_server' doesn't exist: SELECT base.id AS id, base.name AS name, base.machine_name AS machine_name, base.description AS description, base.class AS class, base.options AS options, base.enabled AS enabled, base.status AS status, base.module AS module FROM {search_api_server} base WHERE (base.status IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2)) ; Array ( [:db_condition_placeholder_0] => 3 [:db_condition_placeholder_1] => 2 [:db_condition_placeholder_2] => 6 ) in EntityAPIController->query() (line 187 of /home/website/apps/api/docroot/sites/all/modules/entity/includes/entity.controller.inc).


The question is: where in the database do I need to remove any and all traces that point to this table?

Background:

I figured this was just a module that somehow did not install its tables right somehow. Uninstall, reinstall and done, right?

Two problems:


Uninstalling a module also yields this error, and does not work
The Search API module (http://drupal.org/project/search_api) never was installed at all


It appears the previous developers created a custom module, and named it 'search_api'. My guess is that later they went and did a blanket update of the site modules using drush, and starting updating the custom module far enough to install something to the database. Then they realized their mistake, and replaced the custom module in its original location (but did not rename it).

Nowhere in my modules is there a pointer to the search_api_server table, so it must be somewhere in the database. 

So my plan as it stands is:


Somehow fix the error
Uninstall the custom search_api module
Rename the custom search_api module and reinstall


And I need some help with step 1
I second the voices above.

My recent experience to get out of the pdoexception is crude and more akin to a 'big hammer' rather than anything elegant. 


make a backup of your database and the code   
either use a UI like phpmyadmin OR sql if you feel more comfortable with code
create the table it says is missing (website_staging.search_api_server)
add at least 1 variable (id)... take the defaults of integer
you don't have to add a value to the table, just create it and add the definition for the id variable
try your uninstall again


In my case for my custom module practice development, I also had to add a second variable because there were two 'keys' on the table.  But I'd try this with just the one variable (id)... hopefully it will be enough to get you out of the PDOexception and onward to module/code review.

The concept here is to give Drupal the minimum info it needs via manual PHP/SQL creation so it can 'connect the dots' and move forward to execute your commands (uninstall).
JW