<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div>Ciao,</div><div>volevo sapere se esiste una best practice per quanto riguarda l'esecuzione delle query e l'uso dell'oggetto cursor.</div><div>Per contestualizzare un po' di più ho una classe che in fase di __init__ si collega al database, all'interno della classe una serie di funzioni che fanno delle query.</div><div>Attualmente __init__ crea una istanza di cursor che viene riutilizzata per tutte le query.</div><div><br></div><div style="background-color: transparent;">self.conn = pyodbc.connect(self.DSN,autocommit=False)<br></div><div style="background-color: transparent;">self.conn=conn</div><div style="background-color: transparent;"><span style="background-color: transparent; font-size: 10pt;">self.cur=conn.cursor()</span></div><div style="background-color: transparent; color: rgb(0,
 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;"><span style="background-color: transparent; font-size: 10pt;">(sono omessi i controlli vari)</span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 10pt; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;"><span style="background-color: transparent; font-size: 10pt;"><br></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;"><span style="background-color: transparent; font-size: 10pt;">questo modo di fare è secondo voi corretto o è meglio ad ogni query creare e poi richiudere un nuovo cursor ?</span></div><div style="background-color: transparent; color: rgb(0, 0, 0);
 font-size: 10pt; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;"><span style="background-color: transparent; font-size: 10pt;"><br></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;"><span style="background-color: transparent; font-size: 10pt;">Grazie</span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 10pt; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;"><span style="background-color: transparent; font-size: 10pt;">Piergiorgio</span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 10pt; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;"><span
 style="background-color: transparent; font-size: 10pt;"><br></span></div></div></body></html>