5

Is there a better data type to be using to store a zlib compressed string in Postgresql?

Rhubarb
  • 3,893
  • 6
  • 41
  • 55

2 Answers2

8

Use bytea "The bytea data type allows storage of binary strings"

leonbloy
  • 73,180
  • 20
  • 142
  • 190
nos
  • 223,662
  • 58
  • 417
  • 506
  • Interesting. Any idea what this would be in Django? Meaning what Django field type would yield this type in Postgres? – Rhubarb Jun 02 '10 at 13:31
  • Apparently django doesn't support bytea directly - see http://stackoverflow.com/questions/517349/binaryfields-in-django-models , You could e.g. base64 encode your data and continue to use a text field - though you'd lose some of the benefit of compression – nos Jun 02 '10 at 13:41
  • See [`BinaryField`](https://docs.djangoproject.com/en/1.11/ref/models/fields/#binaryfield). – Phil Krylov Aug 09 '17 at 12:29
4

Use a bytea. Zip compressed data is not a text.

halfdan
  • 33,545
  • 8
  • 78
  • 87