sql - Python always crashes using pydobc connection -


i having hard time pyodbc module (python3). following code crashes python (i run dos terminal). crash happens when main() function returns. data source 4d v13 database remote server. using 4d-odbc driver seems installed not efficient driver. have disabled ssl connection , firewall.

class odbcsource:      def __init__(self, dsn):         self.dsn = str(dsn)         try:             self.con = pyodbc.connect("dsn={}".format(self.dsn))             self.cur = self.con.cursor()             logger.info("odbc source dsn='{}' connected.".format(self.dsn))         except exception err:             self.con = none             self.cur = none             logger.error("cannot connect odbc source dsn='{}': {}.".format(self.dsn, err))      def __bool__(self):         return not(self.con none) or not(self.cur none)      def __str__(self):         return "<cripython.dal.odbcsource id={:#x} dsn='{}'>".format(id(self), self.dsn)      __repr__ = __str__  # main function: def main():     db = odbcsource('cripi-4d')  # program entry point: if(__name__ == "__main__"):     main() 

windows crash window trace give me following informations:

problem signature:   problem event name:   appcrash   application name: python.exe   application version:  0.0.0.0   application timestamp:    5066b7a2   fault module name:    4dodbc.dll   fault module version: 14.0.1.0   fault module timestamp:   53b4d1d6   exception code:   c0000005   exception offset: 00031798   os version:   6.1.7601.2.1.0.256.48   locale id:    2060   additional information 1: 0a9e   additional information 2: 0a9e372d3b4ad19135b953a78882e789   additional information 3: 0a9e   additional information 4: 0a9e372d3b4ad19135b953a78882e789 

i have enabled odbc trace in order check wrong code. have found 3 errors in log.

[...] odbcsource      1724-2a8    enter sqlgettypeinfo          hstmt               0x0059b1f0         sword                       12 <sql_varchar>  odbcsource      1724-2a8    exit  sqlgettypeinfo  return code -1 (sql_error)         hstmt               0x0059b1f0         sword                       12 <sql_varchar>          diag [24000] [microsoft][odbc driver manager] invalid cursor state (0)   odbcsource      1724-2a8    enter sqlgettypeinfo          hstmt               0x0059b1f0         sword                       -9 <sql_wvarchar>  odbcsource      1724-2a8    exit  sqlgettypeinfo  return code -1 (sql_error)         hstmt               0x0059b1f0         sword                       -9 <sql_wvarchar>          diag [24000] [microsoft][odbc driver manager] invalid cursor state (0)   odbcsource      1724-2a8    enter sqlgettypeinfo          hstmt               0x0059b1f0         sword                       -2 <sql_binary>  odbcsource      1724-2a8    exit  sqlgettypeinfo  return code -1 (sql_error)         hstmt               0x0059b1f0         sword                       -2 <sql_binary>          diag [24000] [microsoft][odbc driver manager] invalid cursor state (0)   odbcsource      1724-2a8    enter sqlfreestmt          hstmt               0x0059b1f0         uword                        0 <sql_close>  [...] 

by way, when run script python idle no error @ all. know going wrong code , how should solve it?

an alternative pyodbc, solve crashing issue, use native python driver 4d (p4d) created israel brewster on github.

p4d python database api 2.0 compliant driver 4d (4th dimension) database server. such, usage should familiar has used python database modules before. module based off of c library provided 4d, , integrated python using cffi. such, installation of module require cffi.

the p4d driver built off 4d/sqllib_4d


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -