BUG: Do not error on other dbapi2 connections
State: closed

Do not throw an error in `pandasSQL_builder` when the connection is a dbapi2 connection that is not `sqlite3` and `sqlalchemy` is not installed. Also restores the behaviour prior to #42546 when the connection is a string but `sqlalchemy` is not installed.

This partially addresses #45660 (it removes the requirement for `sqlalchemy` to be installed to use another connection object, however it does not remove the warning that such behaviour is unsupported).

Prior to #42546, other dbapi2 objects would work regardless of whether `sqlalchemy` was installed, without a warning - after this PR, they were not supported. Support was re-added (with a warning) in #45496 , but with an unnecessary requirement on `sqlalchemy`

- [ ] closes #xxxx
- [x] tests added / passed
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit) for how to run them
- [ ] whatsnew entry


Labels:
name: IO SQL
description: to_sql, read_sql, read_sql_query

Comments:
cc @fangchenli 
> @abowden1989 can you add a whatsnew note in 1.4.1 describing this change

@jreback a regression note has been added to the whatsnew for 1.4.1
thanks @abowden1989 
@meeseeksdev backport 1.4.x
Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

1. Checkout backport branch and update it.

```
git checkout 1.4.x
git pull
```

2. Cherry pick the first parent branch of the this PR on top of the older branch:
```
git cherry-pick -m1 4f0e22c1c6d9cebed26f45a9a5b873ebbe67cd17
```

3. You will likely have some merge/cherry-pick conflict here, fix them and commit:

```
git commit -am 'Backport PR #45679: BUG: Do not error on other dbapi2 connections'
```

4. Push to a named branch:

```
git push YOURFORK 1.4.x:auto-backport-of-pr-45679-on-1.4.x
```

5. Create a PR against branch 1.4.x, I would have named this PR:

> "Backport PR #45679 on branch 1.4.x (BUG: Do not error on other dbapi2 connections)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the `Still Needs Manual Backport` label once the PR gets merged.

If these instructions are inaccurate, feel free to [suggest an improvement](https://github.com/MeeseeksBox/MeeseeksDev).
                
Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

1. Checkout backport branch and update it.

```
git checkout 1.4.x
git pull
```

2. Cherry pick the first parent branch of the this PR on top of the older branch:
```
git cherry-pick -m1 4f0e22c1c6d9cebed26f45a9a5b873ebbe67cd17
```

3. You will likely have some merge/cherry-pick conflict here, fix them and commit:

```
git commit -am 'Backport PR #45679: BUG: Do not error on other dbapi2 connections'
```

4. Push to a named branch:

```
git push YOURFORK 1.4.x:auto-backport-of-pr-45679-on-1.4.x
```

5. Create a PR against branch 1.4.x, I would have named this PR:

> "Backport PR #45679 on branch 1.4.x (BUG: Do not error on other dbapi2 connections)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the `Still Needs Manual Backport` label once the PR gets merged.

If these instructions are inaccurate, feel free to [suggest an improvement](https://github.com/MeeseeksBox/MeeseeksDev).
                
@abowden1989 if you can follow the instructions above and push a backport PR would be great.
> @abowden1989 if you can follow the instructions above and push a backport PR would be great.

Thanks @abowden1989 for the PR. backport done in #45754
> > @abowden1989 if you can follow the instructions above and push a backport PR would be great.
> 
> Thanks @abowden1989 for the PR. backport done in #45754

Thanks for taking care of this @simonjayhawkins , I wasn't available the past few days so didn't have chance