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

not pack parameter timestamp #99

Closed
marcioacmauricio opened this issue Oct 31, 2018 · 2 comments
Closed

not pack parameter timestamp #99

marcioacmauricio opened this issue Oct 31, 2018 · 2 comments

Comments

@marcioacmauricio
Copy link

marcioacmauricio commented Oct 31, 2018

I'm trying to run the query through the py-postgresql library and the library is not handling the timestamp parameter
"could not pack parameter $4::TIMESTAMP WITHOUT TIME ZONE for transfer"

INSERT INTO public.example
(ordering, state, checked_out, checked_out_time, created_by, modified_by, name, cep, cpf, cnpj, birth_day, hora_cadastro, email, username, phone_number, website, client_type, user_id, data_bloqueio, user2_id, description)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21)
could not pack parameter $4::TIMESTAMP WITHOUT TIME ZONE for transfer
[
1,
1,
1,
"2018-01-01 01:01:01",
1,
1,
...
1,
1,
"2018-02-22 10:10:00",
1,
"descri\u00e7\u00e3o do item"
]

@marcioacmauricio
Copy link
Author

I managed to resolve past the date as an object and not a string
objDate = datetime.strptime(DateTime, '%d/%m/%Y %H:%M:%S')

@jwp
Copy link
Contributor

jwp commented Nov 18, 2018

I imagine the timestamp was being passed as a builtins.str object. Another alternative would be to cast the parameter as TEXT and then as a TIMESTAMP. This is a feature of the driver providing conversions from Python types to Postgres types(and the reverse). A common means to circumvent the feature is to cast a parameter or column as TEXT.

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