import pyodbc connString = "DSN=vaje" def connect(connString): connection = None while connection is None: try: connection = pyodbc.connect(connString) except Exception as exc: print("ERROR", exc) time.sleep(1) return connection def select(tableName): connection = connect(connString) try: cursor = connection.cursor() data = cursor.execute("SELECT * FROM " + \ tableName).fetchall() for item in data: print(item) except Exception as exc: print("EXCEPTION", exc) connection.close() def test1(): con1 = connect(connString) con1.autocommit = False c1 = con1.cursor() select("test1") c1.execute("update test1 set ocena=6;") select("test1") print("***********") con1.rollback() select("test1") c1.close() con1.close() test1()