• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: psycopg2 SyntaxError with time or date

Resolved: psycopg2 SyntaxError with time or date

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a code that automatically identifies for what table, which columns and what the values to parse into sql insert statement. It works well with all of my tables, except only one. This is a structure of the model of this table:
I got SyntaxError only with this table. My insertion statement:
This is an error:
It’s says in Ukrainian syntax error at or near "current_time". And this values were parsed into the hourly_weather table:
Where current_time is before the last one value.
And yes, I use both psycopg2 and sqlalchemy. There are some reasons for that.

Answer:

I’m not sure I follow all that is going on here (actually, I’m sure that I don’t…) but I think that
  1. Your issue is that current_time is a keyword in PostgreSQL, and

  2. that you should probably use the SQL building features of psycopg2 to handle the necessary quoting for you.


If you have better answer, please add a comment about this, thank you!

psycopg2 python sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why is NGINX’s $request_uri empty?

24/03/2023

Resolved: How to convert Java bytecode to Webassembly using CheerpJ compiler

24/03/2023

Resolved: Is pandas groupby() function always produce a DataFrame with the same order respect to the column we group by?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.