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

panic: pq: invalid input syntax for type timestamp: "2021-11-02 00:00:04.130" #52

Open
TobiasKrok opened this issue Nov 12, 2021 · 3 comments

Comments

@TobiasKrok
Copy link

Hi,

I'm trying to copy values where the date format is like 2021-11-02 00:00:04.130. The table is of type timestamp(3). I tried inserting it manually and it worked. Any idea why it does not let me insert?

@avegao
Copy link

avegao commented Aug 11, 2023

I have the same issue.

I try with

2023-07-20 22:02:38
2023-07-20 22:02:38.000
2023-07-20 22:02:38.000Z
2023-07-20 22:02:38Z
2023-07-20 22:02:38 UTC
2023-07-20 22:02:38.000 UTC
2023-07-20 22:02:38.000 +0
2023-07-20 22:02:38 +0

And always fail.

@miladhub
Copy link

I have the same problem:

$ timescaledb-parallel-copy \
  --connection "host=localhost user=ts sslmode=disable" \
  --db-name ts \
  --table stocks_real_time \
  --file ticks-sample.csv \
  --workers 4 \
  --truncate \
  --verbose \
  --log-batches

panic: ERROR: invalid input syntax for type timestamp with time zone: "time" (SQLSTATE 22007)

goroutine 23 [running]:
main.processBatches(0x0, 0x0)
	/Users/skovola/Documents/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy/main.go:261 +0x8b1
created by main.main
	/Users/skovola/Documents/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy/main.go:161 +0x570

Here's my data file, it's just the first few lines from the original file downloaded from https://docs.timescale.com/getting-started/latest/time-series-data/:

$ cat ticks-sample.csv 
time,symbol,price,day_volume
2023-08-02 23:59:59+00,KO,62,
2023-08-02 23:59:59+00,TSLA,255.44,
2023-08-02 23:59:59+00,DIS,86.41,
2023-08-02 23:59:59+00,KO,62,
2023-08-02 23:59:59+00,DIS,86.41,
2023-08-02 23:59:58+00,PYPL,67.95,
2023-08-02 23:59:58+00,AMD,109.79,
2023-08-02 23:59:58+00,BMY,61.84,
2023-08-02 23:59:57+00,DIS,86.38,

The table is taken from the getting started, https://docs.timescale.com/getting-started/latest/tables-hypertables/:

CREATE TABLE stocks_real_time (
  time TIMESTAMPTZ NOT NULL,
  symbol TEXT NOT NULL,
  price DOUBLE PRECISION NULL,
  day_volume INT NULL
);

The \COPY detailed at https://docs.timescale.com/getting-started/latest/time-series-data/ command works using the same file.

I'm using an M1 MacBookPro, this is the version of timescaledb-parallel-copy:

$ timescaledb-parallel-copy -version
timescaledb-parallel-copy 0.4.1-dev (darwin amd64)

My PostgreSQL version is 14.8 (Homebrew) and the TimescaleDB version is 2.11.1.

@addypy
Copy link

addypy commented Nov 24, 2023

Worked for me once I added the --skip-header flag

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

4 participants