<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mariano Guerra's Log (Publicaciones sobre access)</title><link>http://marianoguerra.org/</link><description></description><atom:link href="http://marianoguerra.org/es/categories/access.xml" rel="self" type="application/rss+xml"></atom:link><language>es</language><lastBuildDate>Mon, 18 Nov 2024 17:56:22 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>migrar access a postgres</title><link>http://marianoguerra.org/es/posts/200810migrar-access-postgres/</link><dc:creator>Mariano Guerra</dc:creator><description>&lt;p&gt;aca hay un pequeño script que hice para migrar de access a postgres, tuve que hacer algunos trucos para que ande bien. si a alguien le sirve...&lt;br&gt;&lt;/p&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span style="color: rgb(0, 112, 32); font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: rgb(14, 132, 181); font-weight: bold;"&gt;os&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 112, 32); font-weight: bold;"&gt;import&lt;/span&gt; &lt;span style="color: rgb(14, 132, 181); font-weight: bold;"&gt;commands&lt;/span&gt;&lt;br&gt;&lt;br&gt;archivo &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(64, 112, 160);"&gt;"archivo.mdb"&lt;/span&gt;&lt;br&gt;&lt;br&gt;tables &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; commands&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;getoutput(&lt;span style="color: rgb(64, 112, 160);"&gt;"mdb-tables -S &lt;/span&gt;&lt;span style="color: rgb(112, 160, 208); font-style: italic;"&gt;%s&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt;"&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102);"&gt;%&lt;/span&gt; (archivo,))&lt;br&gt;os&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;popen(&lt;span style="color: rgb(64, 112, 160);"&gt;"rm carga.sql"&lt;/span&gt;)&lt;br&gt;os&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;popen(&lt;span style="color: rgb(64, 112, 160);"&gt;"rm schema.sql"&lt;/span&gt;)&lt;br&gt;&lt;br&gt;os&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;popen(&lt;span style="color: rgb(64, 112, 160);"&gt;"mdb-schema -S &lt;/span&gt;&lt;span style="color: rgb(112, 160, 208); font-style: italic;"&gt;%s&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt; postgres| sed 's/Postgres_Unknown 0x0c/Text/' | grep &lt;/span&gt;&lt;span style="color: rgb(64, 112, 160); font-weight: bold;"&gt;\"&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt;\-\-&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160); font-weight: bold;"&gt;\"&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt; -v | grep &lt;/span&gt;&lt;span style="color: rgb(64, 112, 160); font-weight: bold;"&gt;\"&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt;^DROP TABLE&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160); font-weight: bold;"&gt;\"&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt; -v | sed 's/Bool/Int8/' &amp;gt; schema.sql"&lt;/span&gt; \&lt;br&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;%&lt;/span&gt; (archivo,))&lt;br&gt;&lt;br&gt;&lt;span style="color: rgb(0, 112, 32); font-weight: bold;"&gt;for&lt;/span&gt; table &lt;span style="color: rgb(0, 112, 32); font-weight: bold;"&gt;in&lt;/span&gt; tables&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;split():&lt;br&gt; cmd &lt;span style="color: rgb(102, 102, 102);"&gt;=&lt;/span&gt; \&lt;br&gt;&lt;span style="color: rgb(96, 160, 176); font-style: italic;"&gt;# si tenes el postgres con locales que te pide insertar la fecha con un&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(96, 160, 176); font-style: italic;"&gt;# formato no ISO (MDY) correr la siguiente linea antes de los inserts&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(96, 160, 176); font-style: italic;"&gt;# SET DateStyle TO 'MDY';&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(64, 112, 160);"&gt;"mdb-export -I -S &lt;/span&gt;&lt;span style="color: rgb(112, 160, 208); font-style: italic;"&gt;%s&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt; &lt;/span&gt;&lt;span style="color: rgb(112, 160, 208); font-style: italic;"&gt;%s&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt; | sed -e 's/)$/)\;/' | sed -e s/&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160); font-weight: bold;"&gt;\\\"&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt;/&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160); font-weight: bold;"&gt;\\&lt;/span&gt;&lt;span style="color: rgb(64, 112, 160);"&gt;'/g &amp;gt;&amp;gt; carga.sql"&lt;/span&gt;&lt;br&gt;&lt;span style="color: rgb(0, 112, 32); font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: rgb(0, 112, 32); font-weight: bold;"&gt;not&lt;/span&gt; table&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;startswith(&lt;span style="color: rgb(64, 112, 160);"&gt;'MSys'&lt;/span&gt;):&lt;br&gt;     os&lt;span style="color: rgb(102, 102, 102);"&gt;.&lt;/span&gt;popen(cmd &lt;span style="color: rgb(102, 102, 102);"&gt;%&lt;/span&gt; (archivo, table))&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;</description><guid>http://marianoguerra.org/es/posts/200810migrar-access-postgres/</guid><pubDate>Fri, 17 Oct 2008 00:57:00 GMT</pubDate></item></channel></rss>