Issue 1:
Describe the bug

Looks like new version is faling in test/ext/mypy/test_mypy_plugin_py3k.py::MypyPluginTest::test_files[plain-keyfunc_dict.py] unit on testing using pytest.

To Reproduce

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
- `python3 -sBm build -w --no-isolation`
- because I'm calling `build` with `--no-isolation` I'm using during all processes only locally installed modules
- install .whl file in </install/prefix>
- run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
- build is performed in env which is *`cut off from access to the public network`* (pytest is executed with `-m "not network"`)

Error

Here is pytest output

Versions

OS: Linux

Python: 3.8.16

SQLAlchemy: 2.0.2

Database: N/A

DBAPI (eg: psycopg, cx_oracle, mysqlclient): N/A

Additional context

Here is list of installed modules in build env

Package Version
----------------------------- -----------------
alabaster 0.7.13
appdirs 1.4.4
attrs 22.2.0
Babel 2.11.0
build 0.9.0
changelog 0.5.8
charset-normalizer 3.0.1
cssselect 1.1.0
Cython 0.29.33
distro 1.8.0
docutils 0.19
exceptiongroup 1.0.0
execnet 1.9.0
extras 1.0.0
fixtures 4.0.0
gpg 1.18.0-unknown
greenlet 1.1.3
idna 3.4
imagesize 1.4.1
importlib-metadata 6.0.0
iniconfig 2.0.0
Jinja2 3.1.2
libcomps 0.1.19
lxml 4.9.2
Markdown 3.4.1
MarkupSafe 2.1.1
mypy 0.990
mypy-extensions 0.4.3
numpy 1.24.1
olefile 0.46
packaging 23.0
pbr 5.9.0
pep517 0.13.0
Pillow 9.4.0
pip 22.3.1
pluggy 1.0.0
Pygments 2.14.0
PyGObject 3.43.1.dev0
pytest 7.2.1
pytest-xdist 3.1.0
python-dateutil 2.8.2
pytz 2022.4
requests 2.28.2
rpm 4.17.0
scour 0.38.2
setuptools 65.6.3
six 1.16.0
smartypants 2.0.1
snowballstemmer 2.2.0
Sphinx 6.1.3
sphinx-copybutton 0.5.1
sphinx-paramlinks 0.5.2
sphinxcontrib-applehelp 1.0.2.dev20221204
sphinxcontrib-devhelp 1.0.2.dev20230202
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jsmath 1.0.1.dev20230128
sphinxcontrib-qthelp 1.0.3.dev20230128
sphinxcontrib-serializinghtml 1.1.5
testtools 2.5.0
toml 0.10.2
tomli 2.0.1
typing_extensions 4.4.0
typogrify 2.0.7
urllib3 1.26.12
wheel 0.38.4
zipp 3.12.0

Issue 2:
Migrated issue, originally created by Anonymous

If a trigger in SQLite raises ROLLBACK, the exception that is propogated to the application is always "OperationalError: SQL logic error or missing database". Here is an example that illustrates the problem (I have attached this file):

from sqlalchemy import *
import sqlite3
DB_NAME = 'test.db3'

def set_up_database():
**
Make a simple table with one (primary key) column, and a trigger that
prevents deletion from the table. Also puts a row into the table.
**
conn = sqlite3.connect(DB_NAME)
cursor = conn.cursor()
cursor.executescript(**
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table(name VARCHAR(10) NOT NULL PRIMARY KEY);
CREATE TRIGGER delete_test_table
BEFORE DELETE ON "test_table"
FOR EACH ROW BEGIN
SELECT RAISE(ROLLBACK, 'Cannot delete from table "test_table"');
END;
INSERT INTO test_table(name) VALUES('first');
**)
cursor.close()
conn.close()

def test_direct_insert():
**
Attempt to duplicate a primary key using direct sqlite3 access. The
exception message should indicate the problem, and it does:
test_direct() insert duplicate error: column name is not unique
**
conn = sqlite3.connect(DB_NAME)
cursor = conn.cursor()
try:
cursor.execute('INSERT INTO test_table(name) VALUES(?)', ('first',))
except Exception, e:
print 'test_direct() insert duplicate error: %s' % e
finally:
cursor.close()
conn.close()

def test_direct_delete():
**
Attempt to delete a row using direct sqlite3 access, but the table's
trigger prevents all deletion. The exception message should indicate
the problem, and it does:
test_direct() deletion error: Cannot delete from table "test_table"
**
conn = sqlite3.connect(DB_NAME)
cursor = conn.cursor()
try:
cursor.execute('DELETE FROM test_table WHERE name=?', ('first',))
except Exception, e:
print 'test_direct() deletion error: %s' % e
finally:
cursor.close()
conn.close()

def test_sqlalchemy_insert():
**
Attempt to duplicate a primary key through SQLAlchemy. The
exception message should indicate the problem, and it does:
test_sqlalchemy() insert duplicate error: (IntegrityError) column name is
not unique u'INSERT INTO test_table (name) VALUES (?)' ['first']('first')
**
db = create_engine('sqlite:///%s' % DB_NAME)
metadata = MetaData(db)
table = Table('test_table', metadata, autoload=True)
#metadata.engine.echo = True
insert_statement = table.insert()
try:
insert_statement.execute(name='first')
except Exception, e:
print 'test_sqlalchemy() insert duplicate error: %s' % e

def test_sqlalchemy_delete():
**
Attempt to delete a row through SQLAlchemy, but the table's trigger
prevents all deletion. The exception message should indicate the
problem, BUT it displays instead:
test_sqlalchemy() deletion error: (OperationalError) SQL logic error
or missing database None None
**
db = create_engine('sqlite:///%s' % DB_NAME)
metadata = MetaData(db)
table = Table('test_table', metadata, autoload=True)
#metadata.engine.echo = True
delete_statement = table.delete()
try:
delete_statement.execute(name='first')
except Exception, e:
print 'test_sqlalchemy() deletion error: %s' % e

if __name__ == '__main__':
set_up_database()
test_direct_insert() # Works fine.
test_direct_delete() # Works fine.
test_sqlalchemy_insert() # Works fine.
test_sqlalchemy_delete() # Doesn't work correctly.

I have tried to find the source of the problem, and it looks like it might be in sqlalchemy.engine.default.do_rollback(). Apparently, the connection.rollback() statement is raising the OperationalError. Note that the error happens only for triggers, not other constraints.

For now, I trap the OperationalError in do_rollback() and toss it, so the original IntegrityError gets propogated to my application. However, I'm not sure whether there is a more-serious underlying problem.

Attachments: sqlite_trigger_problem.py