0

I followed the instructions from here.

Open Data Cube core, version 1.8.6 
Ubuntu 16.04 
SQLAlchemy 1.4.27

After installation tried initialisation of database:

$ datacube -v system init

This command is getting failed with following error:

2021-11-26 16:32:19,396 18775 datacube INFO Running datacube command: /home/user/anaconda2/envs/odc_py38/bin/datacube -v system init
Initialising database...
2021-11-26 16:32:19,698 18775 datacube.drivers.postgres._core INFO Ensuring user roles.
2021-11-26 16:32:19,713 18775 datacube.drivers.postgres._core INFO Creating schema.
2021-11-26 16:32:19,714 18775 datacube.drivers.postgres._core INFO Creating tables.
2021-11-26 16:32:20,219 18775 datacube.drivers.postgres._core INFO Creating triggers.
Traceback (most recent call last):
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1802, in _execute_context
self.dialect.do_execute(
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 719, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.SyntaxError: syntax error at or near "not"
LINE 2: alter table agdc.metadata_type add column if not exists upda...
^
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/user/anaconda2/envs/odc_py38/bin/datacube", line 10, in
sys.exit(cli())
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/datacube/ui/click.py", line 200, in new_func
return f(parsed_config, *args, **kwargs)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/datacube/ui/click.py", line 232, in with_index
return f(index, *args, **kwargs)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/datacube/scripts/system.py", line 51, in database_init
was_created = index.init_db(with_default_types=default_types,
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/datacube/index/index.py", line 64, in init_db
is_new = self._db.init(with_permissions=with_permissions)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/datacube/drivers/postgres/_connections.py", line 201, in init
is_new = _core.ensure_db(self._engine, with_permissions=with_permissions)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/datacube/drivers/postgres/_core.py", line 112, in ensure_db
install_timestamp_trigger(c)
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/datacube/drivers/postgres/_core.py", line 53, in install_timestamp_trigger
connection.execute(UPDATE_COLUMN_MIGRATE_SQL_TEMPLATE.format(schema=SCHEMA_NAME, table=name))
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1274, in execute
return self._exec_driver_sql(
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1578, in _exec_driver_sql
ret = self._execute_context(
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1845, in _execute_context
self.handle_dbapi_exception(
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2026, in handle_dbapi_exception
util.raise(
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise
raise exception
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1802, in _execute_context
self.dialect.do_execute(
File "/home/user/anaconda2/envs/odc_py38/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 719, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.SyntaxError) syntax error at or near "not"
LINE 2: alter table agdc.metadata_type add column if not exists upda...
^

[SQL:
alter table agdc.metadata_type add column if not exists updated
timestamptz default null;
]

Some issues at github had the same problem but were moreover solved by downgrading SQLAlchemy to 1.2 but not in my case.

1
0

It looks like you're using Postgres 9.5, as the add column if not exists feature was added in Postgres 9.6 (in 2016) (which was datacube's previous minimum supported version).

Our minimum requirement is Postgres 10 now, which is also the minimum version still supported by Postgres themselves.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.