Hello,

I got the following code from the website shown in the code.

=======

#!/usr/bin/python3.14
#
# https://runebook.dev/en/docs/python/library/sqlite3/sqlite3.Warning

import sqlite3

try:
    with sqlite3.connect(':memory:') as conn:
        cursor = conn.cursor()

        #  Use executescript() for multiple statements
        sql_script = """
        DROP TABLE IF EXISTS test_table;
        CREATE TABLE test_table (data TEXT);
        INSERT INTO test_table (data) VALUES ('Hello');
        """
        cursor.executescript(sql_script)

        print("Multiple statements executed successfully with executescript().")

except sqlite3.Error as e:
    print(f"Error caught: {e}")
=======
# ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7f0ff158bdf0>

=======

That code is supposed to avoid that message, but I still get the resoure warning.

Is something wrong with my python installation (compiled this morning) or is that a python error?

K.D.J


--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to