3

I am using https://github.com/incuna/django-pgcrypto-fields for pgcrypto in my Django project. It's working fine with inserting, updating fields. But when I am trying something like

MyTable.objects.filter(some_code=somecode).update(
                    some_value=some_price * F('some_units'),
                    updated_on=datetime.now()
                )

Its throwing me psycopg2.errors.UndefinedFunction: function pgp_sym_encrypt(numeric, unknown) does not exist

Any help would be great. Thanks :)

Manoj ahirwar
  • 1,062
  • 1
  • 10
  • 24

1 Answers1

1

To use pgcrypto functions, the pgcrypto extension must be created in the database.

$  psql mydbname -c 'CREATE EXTENSION pgcrypto;'
CREATE EXTENSION
$  psql mydbname -c '\dx'
                            List of installed extensions
   Name    | Version |   Schema   |                   Description                   
-----------+---------+------------+-------------------------------------------------
 pgcrypto  | 1.3     | public     | cryptographic functions
...
snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
  • 1
    Yes. I have pgcrypto installed already. ```ERROR: extension "pgcrypto" already exists``` – Manoj ahirwar Jul 26 '20 at 17:26
  • 1
    Then the next likely cause is that the types of the arguments being passed to the function don't match those in the signature. There's no traceback in the question, so we don't know what's happening in that regard. – snakecharmerb Jul 27 '20 at 17:01