Re: Consulta PyReplica

From: Javier Fritz Alsite <jfritz(dot)aliste(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Consulta PyReplica
Date: 2009-10-02 21:19:38
Message-ID: 4AC66E6A.7030007@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Segun entiendo el metodo a cargo de realizar la conversion entre
pl/python y postgre es mogrify<br>
<br>
<br>
//Extracto del trigger<br>
<br>
&nbsp; # function to convert value from python to postgres representation<br>
&nbsp; def mogrify(v):<br>
&nbsp;&nbsp;&nbsp; if v is None: return 'NULL' <br>
&nbsp;&nbsp;&nbsp; if isinstance(v,basestring): <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r = repr(v)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if not r.startswith('\"'):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return r<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # postgres doesn't support ", replace and escape '<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "'%s'" % r.replace("'","\\'")[1:-1]<br>
&nbsp;&nbsp;&nbsp; return "'%s'" % repr(v) # to get rid of bool that are passed as
ints (solved in pg8.3)<br>
<br>
<br>
quizas deba agregarse alguna condicion en el if??<br>
<br>
saludos.<br>
<br>
<br>
Javier Fritz Alsite wrote:
<blockquote cite="mid:4AC66B0D(dot)8070909(at)gmail(dot)com" type="cite">Hola.<br>
<br>
&nbsp;&nbsp;&nbsp; Como estan, hace algun tiempo pedi ayuda sobre una soluci&oacute;n de
replicaci&oacute;n, he optado por PyReplica , y tengo el siguiente
problema.quizas de simple la soluci&oacute;n, <br>
<br>
&nbsp;&nbsp;&nbsp; Tengo 3 servidores, cada uno tiene conexi&oacute;n con dos maestros
remotos, funciona aceptablemente bien, esta montado en servidores con
salida a internet con un trafico aun de prueba.<br>
<br>
&nbsp;&nbsp;&nbsp; Al grano, al&nbsp; realizar una insercion en una tabla que posee un
campo bigint, el triger esta capturando el query pero para el valor de
este campo lo concatena con "L", no se si esto es correcto, ya que al
ejectuar este query, se por el esclavo&nbsp; pyreplica o extrayendolo
manualmente y ejecutandolo sobre la base genera el error.<br>
<br>
Query capturado por py_log_replica():<br>
<br>
INSERT INTO "sys_tablas" (<b>"id_fila"</b>, "horacreacion",
"tab_fecha5", "tab_fecha4", "tab_fecha3", "tab_fecha2", "tab_fecha1",
"tab_codigo", "uscreacion", "tab_texto2", "tab_texto3", "usmodif",
"tab_texto1", "tab_texto4", "tab_texto5", "tab_valor4", "tab_valor5",
"tab_tipo", "tab_valor1", "tab_valor2", "tab_valor3", "tab_desctabla",
"fecmodif", "horamodif", "tab_codtabla", "feccreacion", "tab_estado",
"tab_desc", "tab_activo") VALUES (<b>'1411<font color="#ff0000">L</font>'</b>,
'161847', '', '', '', '', '', '0102', 'root', '', '', NULL, '', '', '',
'0.0', '0.0', 'S', '1.0', '0.0', '0.0', 'Vendedores', NULL, NULL, '1',
'20091002', '', '0102', 'S')<br>
<br>
la tabla posee casi todos sus campo varchar y posee solo 1 bigint, que
es "id_fila" y el valor entregado segun el triger es 1411L en la tabla
original el query ejecutado es:<br>
<br>
<br>
INSERT INTO "sys_tablas" (<b>"id_fila"</b>, "horacreacion",
"tab_fecha5",
"tab_fecha4", "tab_fecha3", "tab_fecha2", "tab_fecha1", "tab_codigo",
"uscreacion", "tab_texto2", "tab_texto3", "usmodif", "tab_texto1",
"tab_texto4", "tab_texto5", "tab_valor4", "tab_valor5", "tab_tipo",
"tab_valor1", "tab_valor2", "tab_valor3", "tab_desctabla", "fecmodif",
"horamodif", "tab_codtabla", "feccreacion", "tab_estado", "tab_desc",
"tab_activo") VALUES (<b>1411</b>, '161847', '', '', '', '', '',
'0102',
'root', '', '', NULL, '', '', '', 0.0, 0.0, 'S', 1.0, 0.0, 0.0,
'Vendedores', NULL, NULL, '1', '20091002', '', '0102', 'S')<br>
<br>
este ultimo corre sin problemas.<br>
<br>
<br>
<br>
Al ejectuar el primer query directo:<br>
ERROR:&nbsp; error de sintaxis en o cerca de &laquo;L&raquo;<br>
<br>
Al hacerlo con los esclavos corriendo <br>
PyReplica notifica via email (por cada esclavo):<br>
<pre wrap="">Traceback (most recent call last):
File "/usr/local/pyreplica/daemon.py", line 74, in run
debug = self.debug)
File "/usr/local/pyreplica/pyreplica.py", line 154, in main_loop
replicate(cur0, cur1, skip_user, slave_field, debug)
File "/usr/local/pyreplica/pyreplica.py", line 92, in replicate
cur1.execute(sql)
DataError: la sintaxis de entrada no es v&Atilde;&iexcl;lida para integer: &Acirc;&laquo;1411L&Acirc;&raquo;
</pre>
<br>
<br>
<br>
<div class="moz-signature">-- <br>
Javier Fritz<br>
</div>
</blockquote>
<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 4.4 KB

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Mariano Reingart 2009-10-02 21:28:44 Re: Consulta PyReplica
Previous Message Javier Fritz Alsite 2009-10-02 21:05:17 Consulta PyReplica