Data export tool giving "invalid literal" error

Hi,

I'm trying to export data to Postgres.
I get the following error when running this command (note that I've editied the below to hide my passwords - was run with actual passwords inserted)

C:\Users\andre.vanzyl\Documents\PROLIFE\PROLIFE DATA\DATA EXPORTS>commcare-export --output-format sql --output postgresql://postgres:<mypassword>@http://127.0.0.1:5432/testprolife --project prolife --query commcareexports.xlsx --username <myuser> --password <mypwd>
        Traceback (most recent call last):
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\Scripts\commcare-export-script.py", line 11, in <module>
            load_entry_point('commcare-export==1.0.2', 'console_scripts', 'commcare-export')()
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\cli.py", line 291, in entry_point
            main(sys.argv[1:])
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\cli.py", line 124, in main
            exit(main_with_args(args))
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\cli.py", line 228, in main_with_args
            writer = _get_writer(args.output_format, args.output, args.strict_types)
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\cli.py", line 182, in _get_writer
            return writers.SqlTableWriter(output, strict_types)
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\writers.py", line 314, in __init__
            super(SqlTableWriter, self).__init__(db_url, poolclass=poolclass)
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\writers.py", line 261, in __init__
            self.engine = sqlalchemy.create_engine(db_url, poolclass=poolclass)
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\sqlalchemy\engine\__init__.py", line 425, in create_engine
            return strategy.create(*args, **kwargs)
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\sqlalchemy\engine\strategies.py", line 50, in create
            u = url.make_url(name_or_url)
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\sqlalchemy\engine\url.py", line 211, in make_url
            return _parse_rfc1738_args(name_or_url)
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\sqlalchemy\engine\url.py", line 267, in _parse_rfc1738_args
            return URL(name, **components)
          File "C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\sqlalchemy\engine\url.py", line 60, in __init__
            self.port = int(port)
        ValueError: invalid literal for int() with base 10: ''```


Can anyone help me to resolve this error?

Additional info:

Attempting a csv export gave the following:

WARNING: csv output is a zip file, but will be written to testoutput.csv
Consider appending .zip to the file name to avoid confusion.
2018-10-25 11:10:36,861 C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\commcare_hq_client.py WARNING  Request failed after 1 attempts (0.0s). Waiting for retry.
2018-10-25 11:10:38,234 C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\commcare_hq_client.py WARNING  Request failed after 2 attempts (3.1s). Waiting for retry.
2018-10-25 11:10:39,055 C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\commcare_hq_client.py WARNING  Request failed after 3 attempts (3.9s). Waiting for retry.
2018-10-25 11:10:39,871 C:\Users\andre.vanzyl\AppData\Local\Programs\Python\Python37\lib\site-packages\commcare_export\commcare_hq_client.py WARNING  Request failed after 4 attempts (4.8s). Waiting for retry.

Turning my firewall off didn't help either.

Any help would be appreciated.

Hi Andre

There's an error in your PostgreSQL connection string. It shouldn't contain http://.

Please try with this connection string

1 Like

Hi Simon,

It seems like it fixed that problem. Thank you very much.

Best regards,

André