Psycopg2 SQL Statment is working from the query Builder but not from Python

Thagor

The statement I want to use is the following:

UPDATE table SET colum1 = 1  WHERE colum2 LIKE '%gasse%';

when I use exactly this statement everything containing gasse gets updated but when I do this in python with Psycopg2:

sqlstring = """UPDATE table SET colum1 = 1  WHERE colum2 LIKE '%gasse%';"""
cur.execute(sqlstring)

colum1 does not get updated have i done something wrong did i not escape something correctly?

Clodoaldo Neto

It is necessary to commit the transaction that is automatically opened by Psycopg before the first command

connection.commit()

http://initd.org/psycopg/docs/connection.html

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Query works in psql but Syntax error in Python with psycopg2

分類Dev

SQL Server Query not working when executed from PHP

分類Dev

No results from SQL Query

分類Dev

No results from SQL Query

分類Dev

Pythonのpsycopg2で.sqlスキーマを実行する

分類Dev

PostgreSQL copy_from、psycopg2、StringIOを使用した一括挿入

分類Dev

Convert a query from SQL to CodeIgniter

分類Dev

Compose dynamic SQL string with psycopg2

分類Dev

Dynamic SQL with Identifier in psycopg2?

分類Dev

Substract query from another query in SQL Server

分類Dev

Query working in mysql but not from c# code

分類Dev

SQL Sub-Query from 2 Access Queries

分類Dev

Cloud sql proxy not working from docker container

分類Dev

change the type of the query result from DB2 via python

分類Dev

Why is this simple (nested) if statment not working?

分類Dev

Looping result from SQL select query

分類Dev

SQL Query for max value from subsets

分類Dev

Decode text from a FOR XML Sql Query

分類Dev

JSON from SQL query with child level

分類Dev

Query from multiple XML columns in SQL Server

分類Dev

How to make a dynatree from sql query results?

分類Dev

SQL query: combining data from two tables

分類Dev

Sql query selecting from both tables.

分類Dev

Output complex xml from SQL select query

分類Dev

SQL query condition not working

分類Dev

SQL Query not working perfectly

分類Dev

How to query specific column name from multiple table from SQL

分類Dev

SQL Query - Query on Current Date but condition from the past

分類Dev

SQL Query between two dates from sub query