question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Go postgresql drivers cannot parse date from crate

See original GitHub issue

CrateDB version: 2.2.5

JVM version: 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12

OS version / environment description: Ubuntu 16.04

Problem description:

go drivers cannot parse date from both pg and pgx

log from lib/pq expected end of input, got +00 AD []

log from pgx parsing time "2018-01-10 00:00:00.000 +00 AD" as "2006-01-02 15:04:05.999999999Z07:00": cannot parse " +00 AD" as "Z07:00" []

Steps to reproduce:

Run crate by docker run -d -p 4200:4200 -p 4300:4300 -p 5432:5432 crate crate -Cnetwork.host=_site_

Execute the go code

package main

import (
	"log"
	"time"

	_ "github.com/jackc/pgx/stdlib"
	"github.com/jmoiron/sqlx"
	_ "github.com/lib/pq"
)

func main() {
	db := sqlx.MustConnect("postgres", "postgres://crate:@localhost:5432/doc?sslmode=disable").Unsafe()
	// db := sqlx.MustConnect("pgx", "postgres://crate:@localhost:5432/doc?sslmode=disable").Unsafe()

	db.MustExec("drop table if exists test")
	db.MustExec("create table if not exists test ( t timestamp )")
	db.MustExec("insert into test values ('2018-01-10T00:00:00Z')")

	time.Sleep(time.Second) // wait until data is queryable, raise the value if no error is printed

	result := []struct {
		T time.Time `db:"t"`
	}{}
	log.Println(db.Select(&result, "select * from test"), result)
}

Use case:

Feature description:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
matrivcommented, Jan 18, 2018

Issue has been fixed and will be released with the next hotfix releases.

1reaction
felixgecommented, Jan 11, 2018

@mikethebeer I’ll try to have a look this weekend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pgx - PostgreSQL Driver and Toolkit - Go Packages
Package pgx is a PostgreSQL database driver. ... floats, strings, dates, and times that have direct mappings between Go and SQL.
Read more >
How to parse date from string in Golang to insert into Postgres?
To parse time in your example you'll need correct layout passed to time.Parse : layout := "2006-01-02" updatedAt, _ := time.Parse(layout, "2016-06-10") fmt....
Read more >
sqlx - crates.io: Rust Package Registry
SQLx is an async, pure Rust† SQL crate featuring compile-time checked queries without a DSL. Truly Asynchronous. Built from the ground-up ...
Read more >
Engine Configuration — SQLAlchemy 2.0 Documentation
Release: 2.0.0b4 beta release | Release Date: December 5, 2022 ... from sqlalchemy import create_engine engine = create_engine("postgresql+psycopg2://scott: ...
Read more >
What's New - Oracle Linux Yum Server
pspg-5.5.13-1.el7 - A unix pager optimized for psql (Update) ... Parse command line argument by defining a struct, derive crate (New) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found