Author petr.viktorin
Recipients erlendaasland, petr.viktorin
Date 2021-09-08.07:45:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This is a minefield. If anyone has a use case for it, I'd *love* to hear it, but to me it seems that proper reinit support will be a lot of work (now and in future maintenance) for no gain. You can always create a new connection object.

Consider instead deprecating reinitialization, documenting it as unpredictable & removing it in Python 3.13.

Here's another thing to test:
import sqlite3

conn = sqlite3.connect(':memory:')
cursor = conn.execute('CREATE TABLE foo (bar)')

except sqlite3.OperationalError:

cursor.execute('INSERT INTO foo (bar) VALUES (1), (2), (3), (4)')

And here's the kind of behavior that should be specified (and tested), and might even change to make more sense:
import sqlite3

conn = sqlite3.connect(':memory:')
conn.row_factory = sqlite3.Row
cursor = conn.execute('CREATE TABLE foo (bar)')
cursor.execute('INSERT INTO foo (bar) VALUES ("1"), ("2"), ("3"), ("4")')
cursor.execute('SELECT bar FROM foo')

for row in cursor:
    print(row, list(row))

conn.execute('CREATE TABLE foo (bar)')
conn.execute('INSERT INTO foo (bar) VALUES ("a"), ("b"), ("c"), ("d")')

# Currently this uses the old database, old row_factory, but new text_factory"
for row in cursor:
    print(row, list(row))

We should also do a review of all places `connection` is used from Cursor, Statement, etc. to ensure everything continue to work with a different `db`. This can be done (and maybe you already did), but I'm also worried how well future maintainers can keep reinitialization in mind.

And all this will also need to be done for Cursor.
Date User Action Args
2021-09-08 07:45:28petr.viktorinsetrecipients: + petr.viktorin, erlendaasland
2021-09-08 07:45:28petr.viktorinsetmessageid: <>
2021-09-08 07:45:28petr.viktorinlinkissue45126 messages
2021-09-08 07:45:27petr.viktorincreate