sql-update

Getting unexpected result when trying to update a cell

"no such column" error when trying to update Question: I am trying to replace a string with an id: import sqlite3 TABLES = [‘table1’, ‘table2’, …] PAR_TYPES_STRINGS = [‘foo’, ‘bar’, …] PAR_TYPES_ID = [1, 2, …] def upateTable(table, parTypeId, parTypeString): return f"UPDATE {table} SET par_type = {parTypeId} WHERE par_type = {parTypeString};" conn = sqlite3.connect(‘existing_db.db’) cursor …

Total answers: 1

sql update a column afther reach same amount 1ns

sql update a column afther reach same amount 1ns Question: i have a function that needs to update all rows to 0 after colum 1(selection) and column 2(savecounter) have same amount 1ns I have made some save systhem it needs to work like this. I got multiple employee, after i use a button 2 mails …

Total answers: 1

How to set all rows in column 0 when all rows reach 1

How to set all rows in column 0 when all rows reach 1 Question: i have a function that needs to update all rows to 0 after all rows have 1.. I have made some save systhem it needs to work like this. I got multiple employee, after i use a button 2 mails will …

Total answers: 1

How to update rows in a BigQuery table using airflow

How to update rows in a BigQuery table using airflow Question: I am coding a DAG and want to execute an UPDATE statement to selectively set the values of certain fields in certain rows. The SQL statement is easy, but I am not sure how to execute it via Airflow. The documentation on BigQueryUpdateTableOperator here …

Total answers: 2

psycopg2: update multiple rows with one query

psycopg2: update multiple rows with one query Question: I tried to update multiple rows (approx. 350000) with a single query by implementing the following function: def update_items(rows_to_update): sql_query = """UPDATE contact as t SET name = e.name FROM (VALUES %s) AS e(id, name) WHERE e.id = t.id;""" conn = get_db_connection() cur = conn.cursor() psycopg2.extras.execute_values ( …

Total answers: 2

Update a PostgreSql table using a Python variable

Update a PostgreSql table using a Python variable Question: I have the following table in my PostgreSql database with 1 row of data. I want to update the value in the “diagnosis” column (currently 3) to another number. My python code is below: Based on my code below, the “diagnosis” column should equal whatever number …

Total answers: 1

psycopg2 syntax error at or near "UPDATE"

psycopg2 syntax error at or near "UPDATE" Question: I’ve read some q&a about "syntax error at or near" but none could solve my issue. A sample of the error: Traceback (most recent call last): File "<stdin>", line 1, in <module> psycopg2.ProgrammingError: syntax error at or near "UPDATE" LINE 1: DECLARE "teste" CURSOR WITHOUT HOLD FOR …

Total answers: 1

Can I "touch" a SQLAlchemy record to trigger "onupdate"?

Can I "touch" a SQLAlchemy record to trigger "onupdate"? Question: Here’s a SQLAlchemy class: class MyGroup(Base): __tablename__ = ‘my_group’ group_id = Column(Integer, Sequence(‘my_seq’), primary_key=True) group_name = Column(String(200), nullable=False, index=True) date_created = Column(DateTime, default=func.now()) date_updated = Column(DateTime, default=func.now(), onupdate=func.now()) Anytime I add a group_name or (for example) update the group_name, the date_updated field will get updated. …

Total answers: 4

Python mySQL Update, Working but not updating table

Python mySQL Update, Working but not updating table Question: I have a python script which needs to update a mysql database, I have so far: dbb = MySQLdb.connect(host=”localhost”, user=”user”, passwd=”pass”, db=”database”) try: curb = dbb.cursor() curb.execute (“UPDATE RadioGroups SET CurrentState=1 WHERE RadioID=11”) print “Row(s) were updated :” + str(curb.rowcount) curb.close() except MySQLdb.Error, e: print “query …

Total answers: 4