[python-win32] Message: 4 -- Re: How can improvement time of response of Python cx_Oracle
Mauricio Martinez Garcia
morfeokmg at gmail.com
Thu Jun 17 19:55:12 CEST 2010
Tanks for the response.
The next change modified the time of response and its more best.
Old Time: 1 - 2 mins by rows
New Time: 1.58548355103e-06 - 5.64257303874e-07 segs prom.
This it is an example:
LOG_PYTHON: Iniciando el proceso de conciliacion
espere...
2010-06-05
06:19:51.180799
1--6.00020090739e-07--LOG_PYTHON: 522226163232|6416764|6416764|10|10|s|
s|CPLUS015|CPLUS015|AC|0|364|0
2--6.00020090739e-07--LOG_PYTHON: 527442169944|6417057|6417057|10|10|s|
s|CPLUS215|CPLUS215|AC|0|364|2.27
....
19269--7.15255737305e-07--LOG_PYTHON: 524641251912|7841944|7841944|10|
10|s|s|CCT116|CCT116|AC|0|446.5|0
19270--5.64257303874e-07--LOG_PYTHON: 528442476903|7882244|7882244|10|
10|s|s|CCT116|CCT116|AC|0|446.5|0.64
Change the module
=======================================================
def creaConexion(self,v_user, v_passwd, v_schema)....
=======================================================
with the new module
=======================================================
def creaConexion(self,v_user, v_passwd, v_schema):
if (v_schema == "PREPAGO"):
try:
ds = cx_Oracle.makedsn(self.SERV_PREPAGO,
self.PORT_PREPAGO, self.SID_PREPAGO)
pool = cx_Oracle.SessionPool(user = v_user,
password= v_passwd,
dsn = ds,
min=5,
max=10,
increment=1,
connectiontype=cx_Oracle.Connection,
threaded=False,
getmode=cx_Oracle.SPOOL_ATTRVAL_NOWAIT,
homogeneous=True
)
#connection = cx_Oracle.connect(v_user, v_passwd,ds)
connection = pool.acquire()
return connection
=======================================================
The change its an pool connection vs an cx_Oracle.connect()
GREETINGS
On Fri, 2010-06-04 at 12:00 +0200, python-win32-request at python.org
wrote:
> Send python-win32 mailing list submissions to
> python-win32 at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/python-win32
> or, via email, send a message with subject or body 'help' to
> python-win32-request at python.org
>
> You can reach the person managing the list at
> python-win32-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of python-win32 digest..."
>
>
> Today's Topics:
>
> 1. How can improvement time of response of Python cx_Oracle
> (Mauricio Martinez Garcia)
> 2. python 2.5.1 and MSVC++ 2008 (Heather Kelly)
> 3. Re: python 2.5.1 and MSVC++ 2008 (Trent Nelson)
> 4. Re: How can improvement time of response of Python cx_Oracle
> (Trent Nelson)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 03 Jun 2010 12:50:18 -0500
> From: Mauricio Martinez Garcia <morfeokmg at gmail.com>
> To: python-win32 at python.org
> Subject: [python-win32] How can improvement time of response of Python
> cx_Oracle
> Message-ID: <4C07EB5A.3000803 at gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi.
>
> This is my code for Oracle Connection with python and cx_Oracle.
>
> How can improvement time of response?.
>
> #==========================================================
>
> #Este metodo crea una conexion a oracle
>
> def creaConexion(self,v_user, v_passwd, v_schema):
>
> rowsSchema = v_schema.split(",")
>
> v_server = str(rowsSchema[0])
>
> v_port = int(rowsSchema[1])
>
> v_sid = str(rowsSchema[2])
>
> dsn = cx_Oracle.makedsn(v_server, v_port, v_sid)
>
> try:
>
> connection = cx_Oracle.connect(v_user, v_passwd,dsn)
>
> return connection
>
>
> except cx_Oracle.DatabaseError, exc:
>
> error, = exc.args
>
> print >> sys.stderr, XP_ERROR+"Oracle-Error-Code:",
> error.code
>
> print >> sys.stderr, XP_ERROR+"Oracle-Error-Message:",
> error.message
>
> sys.exit(1)
>
>
> #metodo que ejecuta un query en oracle
>
> def ejecutaQuery(self, query, conn):
>
> cursor = conn.cursor()
>
> cursor.arraysize = 10000
>
> try:
>
> cursor.parse(query)
>
> cursor.execute(query)
>
> cursorReturn = cursor.fetchall()
>
> return cursorReturn
>
>
> except cx_Oracle.DatabaseError, exc:
>
> error, = exc.args
>
> print >> sys.stderr, XP_ERROR+"Oracle-Error-Code:", error.code
>
> print >> sys.stderr, XP_ERROR+"Oracle-Error-Message:",
> error.message
>
> print query
>
> sys.exit(1)
>
> #==========================================================
>
> The time for an comparation of 2 DBs are many.
> Python: 1 - 2 mins by rows.
> Java 0.02 - 0.10 secs by rows.
>
>
> my code for comparation
>
> #============================================================
>
> n = 1
>
> iniciaconexionBSCS = OracleConnections()
>
> iniciaconexionATS = OracleConnections()
>
> #Realizamos la conexion a oracle.
>
> conn = iniciaconexionBSCS.creaConexion(usrBSCS, pasBSCS, 'BSCSP')
>
> conn2 = iniciaconexionATS.creaConexion(usrATS, passATS,
> 'ATSP')
>
> for rows in tuplaTotal:
>
> BODY_SQL_BSCS = TMPLT_BSCS % (rows.telefono)
>
> BODY_SQL_ATS = TMPLT_ATS % (rows.telefono)
>
> error_co_id = '0'
>
> error_ciclo = '0'
>
> error_pt = '0'
>
> error_status = '0'
>
> error_activacion = '0'
>
> error_saldo = '0'
>
> #print BODY_SQL_BSCS
>
> #print BODY_SQL_ATS
>
>
>
> ejecBSCS = iniciaconexionBSCS.ejecutaQuery(BODY_SQL_BSCS,
> conn)
>
> ejecATS = iniciaconexionATS.ejecutaQuery(BODY_SQL_ATS, conn2)
>
> for rowsBSCS in ejecBSCS:
>
> for rowsATS in ejecATS:
>
> #Ejemplos de salida
>
> #BS (3404, 7956771, '5546037825', '10', 'a', 'CCT116')
>
> #AT ('7956771', '5546037825', '334010011470558',
> '10', 'a', 'CCT116', 'AC', 0, 335.35000000000002, 0)
>
> if ((str(rowsBSCS[2]) == str(rowsATS[1])) and
> ((int(rowsBSCS[1]) <> int(rowsATS[0])) or (str(rowsBSCS[3]) <>
> str(rowsATS[3])) or (str(rowsBSCS[4]) <> str(rowsATS[4])) or
> (str(rowsBSCS[5]) <> str(rowsATS[5])) or (str(rowsATS[6]) == 'CR') or
> (rowsATS[7] < 0) or (rowsATS[8] < 0) or (rowsATS[9] < 0))):
>
> print 'DN Con error: '+rows.telefono
>
> if (int(rowsBSCS[1]) <> int(rowsATS[0])):
>
> error_co_id = '1'
>
> elif (str(rowsBSCS[3]) <> str(rowsATS[3])):
>
> error_ciclo = '1'
>
> elif (str(rowsBSCS[4]) <> str(rowsATS[4])):
>
> error_status = '1'
>
> elif (str(rowsBSCS[5]) <> str(rowsATS[5])):
>
> error_pt = '1'
>
> elif (str(rowsATS[6]) == 'CR'):
>
> error_activacion = '1'
>
> elif ((rowsATS[7] < 0) or (rowsATS[8] < 0) or
> (rowsATS[9] < 0)):
>
> error_saldo = '1'
>
> DNIncorrecto =
> str(rowsATS[1])+"|"+str(rowsBSCS[1])+"|"+str(rowsATS[0])+"|"+str(rowsBSCS[3])+"|"+str(rowsATS[3])+"|"+str(rowsBSCS[4])+"|"+str(rowsATS[4])+"|"+str(rowsBSCS[5])+"|"+str(rowsATS[5])+"|"+str(rowsATS[6])+"|"+str(rowsATS[7])+"|"+str(rowsATS[8])+"|"+str(rowsATS[9])+"|"+error_co_id+"|"+error_ciclo+"|"+error_status+"|"+error_pt+"|"+error_activacion+"|"+error_saldo+"|"+error_co_id+error_ciclo+error_status+error_pt+error_activacion+error_saldo
>
> print str(n)+"--"+XP_LOG+DNIncorrecto
>
> #n = n + 1
>
> else:
>
> DNCorrecto =
> str(rowsATS[1])+"|"+str(rowsBSCS[1])+"|"+str(rowsATS[0])+"|"+str(rowsBSCS[3])+"|"+str(rowsATS[3])+"|"+str(rowsBSCS[4])+"|"+str(rowsATS[4])+"|"+str(rowsBSCS[5])+"|"+str(rowsATS[5])+"|"+str(rowsATS[6])+"|"+str(rowsATS[7])+"|"+str(rowsATS[8])+"|"+str(rowsATS[9])
>
> print str(n)+"--"+XP_LOG+DNCorrecto
>
> #n = n + 1
>
>
> #print str(n), rows.telefono
>
> n = n + 1
>
> iniciaconexionBSCS.cierraConexion(conn)
>
> iniciaconexionATS.cierraConexion(conn2)
>
>
> #============================================================
>
> I need improvement the time of response of 1 - 2 minutes to 0.02 -
> 0.10 secs. How can this?.
>
> GREETINGS.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQIcBAEBAgAGBQJMB+tZAAoJEFWGNhWbCcUY5vIP/AlE7nTFzX+HkLPq3Lj6yj9s
> 6yFYRIlcJwX+QEa0PGPXDcJ/nJw5uqLNsKZW2v7R5zmeDmX7BSUx0nO57xju/sEB
> PnRBYrqXBKd1GvJU46SUJi2ahQx7y37ctzjU9l2sdZ/74JrSWiW1L3Ip4DJnlohR
> hgmS6PfTx4IvHb26Pn8Sxa5UGmL0OGVrW7b/U9BI+IAXjkXMnrmVQKbaInBIrE3m
> ZGCwsySTjfSKEhH9ybOVhk4CZHkeRY2wKNv4YZ98++sSkrCFMhdnoPM0fMAsAEN2
> sgQhZ9ziNCtpiyGmtL/QVkxeQhwNwpnixrkXf96FfzeVLESwf2117m3RcTntLWKC
> ixvOOHV2gCF6YCf5UKucQEq8V/D1UgPliPU4pacBvq/5/Xq3zoJxOWxnHRZRiUtA
> /UgGnhn+7vHvhiYTXJtJrI95i6YyR7mud0ZuWcc7pYGZ6kJ1toIZIgqeLxvK33u0
> OrQUOf0n6j+JWS9DiJRrIMhhRPr8IX5pjGg6GfqfcQBKUcJuJnLzev57GFTQHcCl
> S18lkASTykWV3SPdAc6mmAf2Pv/B2X8CFZk9Oc9kgnqYUVFyikCY4GRv7GCnMucQ
> 1yYoWT5nz/N9+6SeLkGGhS9nxWL/OJlepYR66shJR4J/1K1Qp5BERhOtLMX5f2kK
> L8MNhHxT1IictTauhp0D
> =wckT
> -----END PGP SIGNATURE-----
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 03 Jun 2010 14:14:15 -0400
> From: Heather Kelly <heather625 at gmail.com>
> To: python-win32 at python.org
> Subject: [python-win32] python 2.5.1 and MSVC++ 2008
> Message-ID: <4c07f0fd.e22be50a.1dc5.17b7 at mx.google.com>
> Content-Type: text/plain; charset="us-ascii"; format=flowed
>
> Hi,
>
> I work on a project that still supports 2.5.1 for now (we plan to
> upgrade to 2.6 in the near future). In the meantime, we are moving
> to MSVC++ 2008 from MSVC++ 2003. Up to now, we have been using the
> binary distribution of python, but I believe to support MSVC++ 2008,
> we now must build python 2.5.1 ourselves. Actually, I've already
> built python itself, but I have run into trouble trying to build
> tcl/tk 8.4, which comes with support for MSVC++ 6.
>
> now for my questions.. am I wrong that I need to rebuilt python
> 2.5.1 to fully support our MSVC++ users who only have MSVC++ 2008 on
> their systems? Could I just provide them a couple specific MSVC++
> 2003 libraries and they'll be fine?
>
> Has anyone else managed to build the tcl/tk with MSVC++ 2008?
>
> Would these troubles disappear if we just upgrade to python 2.6 now?
>
> Are there any web pages out there that discuss building python and
> its associated components from scratch?
>
> Thanks,
> Heather
>
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 3 Jun 2010 15:13:46 -0400
> From: Trent Nelson <trent at snakebite.org>
> To: <python-win32 at python.org>
> Subject: Re: [python-win32] python 2.5.1 and MSVC++ 2008
> Message-ID: <4C07FEEA.2040900 at snakebite.org>
> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
>
> On 6/3/2010 2:14 PM, Heather Kelly wrote:
> > Hi,
> >
> > I work on a project that still supports 2.5.1 for now (we plan to
> > upgrade to 2.6 in the near future). In the meantime, we are moving
> > to MSVC++ 2008 from MSVC++ 2003. Up to now, we have been using the
> > binary distribution of python, but I believe to support MSVC++ 2008,
> > we now must build python 2.5.1 ourselves. Actually, I've already
> > built python itself, but I have run into trouble trying to build
> > tcl/tk 8.4, which comes with support for MSVC++ 6.
> >
> > now for my questions.. am I wrong that I need to rebuilt python
> > 2.5.1 to fully support our MSVC++ users who only have MSVC++ 2008 on
> > their systems? Could I just provide them a couple specific MSVC++
> > 2003 libraries and they'll be fine?
> >
> > Has anyone else managed to build the tcl/tk with MSVC++ 2008?
> >
> > Would these troubles disappear if we just upgrade to python 2.6 now?
>
> I'd highly recommend taking that approach. The compiler toolchain
> doesn't change for a m.n release (i.e. 2.5.x, 2.6.x). If your strongest
> requirement is MSVC++ 2008 support, I'd go with 2.6.
>
> > Are there any web pages out there that discuss building python and
> > its associated components from scratch?
>
> The buildbots are a good place to start:
> http://svn.python.org/projects/python/branches/release26-maint/Tools/buildbot/
>
> The external*.bat scripts in that directory take care of building all
> the external dependencies, like Tcl/Tk. (And from that, you'll be able
> to see where we grab Tcl/Tk from (svn.python.org/contrib), and all the
> fiddling we had to do to get that building properly with a non-vc6
> toolchain).
>
> Trent.
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 3 Jun 2010 15:16:50 -0400
> From: Trent Nelson <trent at snakebite.org>
> To: <python-win32 at python.org>
> Subject: Re: [python-win32] How can improvement time of response of
> Python cx_Oracle
> Message-ID: <4C07FFA2.4000701 at snakebite.org>
> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
>
> On 6/3/2010 1:50 PM, Mauricio Martinez Garcia wrote:
> > The time for an comparation of 2 DBs are many.
> > Python: 1 - 2 mins by rows.
> > Java 0.02 - 0.10 secs by rows.
>
> > I need improvement the time of response of 1 - 2 minutes to 0.02 -
> > 0.10 secs. How can this?.
>
> Out of interest, have you ruled out that the Python overhead isn't
> incurred by just establishing the connection? Oracle interop can be
> funny sometimes -- underlying configuration oddities can hang initial
> connection attempts by a couple of minutes.
>
> How long does it take to establish a connection and run a dummy query?
>
> Trent.
>
>
> ------------------------------
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
> End of python-win32 Digest, Vol 87, Issue 3
> *******************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100617/74a17381/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100617/74a17381/attachment-0001.pgp>
More information about the python-win32
mailing list