Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use postgresql conn string not working #340

Open
beckietech opened this issue Jul 3, 2024 · 8 comments
Open

use postgresql conn string not working #340

beckietech opened this issue Jul 3, 2024 · 8 comments

Comments

@beckietech
Copy link

beckietech commented Jul 3, 2024

terracotta, version 0.8.3

config.toml:

DRIVER_PATH = "postgresql+psycopg2://postgres:[password]@localhost:5432/terracotta"
DRIVER_PROVIDER = postgresql
terracotta -c /home/bill/config.toml ingest /home/bill/optimized/{date}_forecast.tif -o /home/bill/test.sqlite
Uncaught exception!
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 511, in loads
    ret = decoder.load_line(line, currentlevel, multikey,
  File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 778, in load_line
    value, vtype = self.load_value(pair[1], strictly_valid)
  File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 910, in load_value
    raise ValueError("This float doesn't have a leading "
ValueError: This float doesn't have a leading digit

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/terracotta/scripts/cli.py", line 63, in entrypoint
    cli(obj={})
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1077, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 943, in make_context
    self.parse_args(ctx, args)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1644, in parse_args
    rest = super().parse_args(ctx, args)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1408, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 2400, in handle_parse_result
    value = self.process_value(ctx, value)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 2356, in process_value
    value = self.type_cast_value(ctx, value)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 2344, in type_cast_value
    return convert(value)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 2316, in convert
    return self.type(value, param=self, ctx=ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/types.py", line 83, in __call__
    return self.convert(value, param, ctx)
  File "/usr/local/lib/python3.9/dist-packages/terracotta/scripts/click_types.py", line 129, in convert
    return dict(toml.load(value))
  File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 134, in load
    return loads(ffile.read(), _dict, decoder)
  File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 514, in loads
    raise TomlDecodeError(str(err), original, pos)
toml.decoder.TomlDecodeError: This float doesn't have a leading digit (line 2 column 1 char 82)

am I doing it wrong? please advise! Thank you!

@dionhaefner
Copy link
Collaborator

What's in your config.toml file? Looks like Terracotta can't parse it.

@beckietech
Copy link
Author

beckietech commented Jul 3, 2024 via email

@dionhaefner
Copy link
Collaborator

You forgot to quote DRIVER_PROVIDER:

DRIVER_PROVIDER = "postgresql"

@beckietech
Copy link
Author

@dionhaefner, thnak you! After added quotes, it started ingesting!

However, I didn't see changes added in target database. Can you show me some example what to expect after this action?

Best regards,

@beckietech
Copy link
Author

and also when i brwose the map, on upper right corner, it says: Search for datasets ... and spinning. I don't know if this is correct.

@dionhaefner
Copy link
Collaborator

terracotta ingest can only ingest into SQLite databases. For advanced use cases like postgres, please use the Python API.

@beckietech
Copy link
Author

@dionhaefner, thank you. Since I am newbee to GIS, when I look at python code, I wonder how can I get keys from raster, for example: KEYS = ["type", "rp", "rcp", "epoch", "gcm"] ; KEYS = ('sensor', 'tile', 'date', 'band'), is there tools / methods to describe a raster file?

@dionhaefner
Copy link
Collaborator

Keys are arbitrary values that identify a dataset - you are free to choose whatever you want. In your example ingest command, the only key would be date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants