You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.1 KiB

7 years ago
  1. <section class="oe_container">
  2. <div class="oe_row oe_spaced">
  3. <h2 class="oe_slogan">MuK PGSQL Large Objects</h2>
  4. <h3 class="oe_slogan">PGSQL Large Objects Support</h3>
  5. <h4 class="oe_slogan" style="font-size: 23px;">MuK IT GmbH -
  6. www.mukit.at</h4>
  7. </div>
  8. </section>
  9. <section class="oe_container">
  10. <div class="oe_row oe_spaced">
  11. <div class="oe_picture">
  12. <h3 class="oe_slogan">Overview</h3>
  13. <div class="oe_mt32"
  14. style="padding-bottom: 10px; text-align: justify;">
  15. <p>Provides a field to store bytes as PostgreSQL large objects.
  16. PostgreSQL offers support for large objects, which provide
  17. stream-style access to user data that is stored in a special
  18. large-object structure. They are useful with data values too large
  19. to be manipulated conveniently as a whole.</p>
  20. <h5 style="padding-top: 10px;">Psycopg2 for Python</h5>
  21. <p>
  22. Psycopg allows access to the large object using the
  23. <code>lobject</code>
  24. class. Objects are generated using the
  25. <code>connection.lobject()</code>
  26. factory method. Data can be retrieved either as bytes or as Unicode
  27. strings.
  28. </p>
  29. <p>
  30. Psycopg large object support efficient import/export with file
  31. system files using the
  32. <code>lo_import()</code>
  33. and
  34. <code>lo_export()</code>
  35. libpq functions.
  36. </p>
  37. <p>Changed in version 2.6: added support for large objects
  38. greated than 2GB. Note that the support is enabled only if all the
  39. following conditions are verified:</p>
  40. <ul>
  41. <li>the Python build is 64 bits;</li>
  42. <li>the extension was built against at least libpq 9.3;</li>
  43. <li>the server version is at least PostgreSQL 9.3
  44. (server_version must be >= 90300).</li>
  45. </ul>
  46. <p>
  47. If Psycopg was built with 64 bits large objects support (i.e. the
  48. first two contidions above are verified), the
  49. <code>psycopg2.__version__</code>
  50. constant will contain the lo64 flag. If any of the contition is not
  51. met several lobject methods will fail if the arguments exceed 2GB.
  52. </p>
  53. </div>
  54. <pre>
  55. <code>
  56. from odoo.addons.muk_fields_lobject import fields as lobject_fields
  57. class LargeObjectModel(models.Model):
  58. data_content = lobject_fields.LargeObject(string="Data")
  59. @api.multi
  60. def data(self):
  61. for record in self:
  62. bytes = record.data_content
  63. oid = record.with_context({'oid': True}).data_content
  64. size = record.with_context({'bin_size': True}).data_content
  65. stream = record.with_context({'stream': True}).data_content
  66. </code>
  67. </pre>
  68. </div>
  69. </div>
  70. </section>
  71. <section class="oe_container oe_dark" style="margin-top: 450px;">
  72. <h3 class="oe_slogan">Help and Support</h3>
  73. <div class="oe_slogan">
  74. <a class="btn btn-primary btn-lg mt8" href="mailto:sale@mukit.at">
  75. <i class="fa fa-envelope"></i> Email
  76. </a> <a class="btn btn-primary btn-lg mt8"
  77. href="https://mukit.at/page/contactus"> <i class="fa fa-phone"></i>
  78. Contact
  79. </a>
  80. </div>
  81. <img src="logo.png" style="width: 200px; margin-bottom: 20px;"
  82. class="center-block">
  83. </section>