sql

Delete all Occurences of a Substring in SQL-Statement in Python

Delete all Occurences of a Substring in SQL-Statement in Python Question: I have a file from a mariadb containing 3GBs of SQL-Statements. Problem is, that my SQLlite DB doesn’t support the contained Key-Statements. Is there a way to edit the Strings containing the Statements that cuts out all substrings that follow the pattern ,"Key",? I …

Total answers: 2

Spark SQL – Pivot and concatenation

Spark SQL – Pivot and concatenation Question: I am working with spark sql and have a requirement to pivot and concatenate the data. My input data looks like ID Quantity Location 1 10 US 2 20 UK 2 5 CA 2 20 US 3 15 US 3 20 CA 4 25 US 4 10 CA …

Total answers: 1

Compute maximum number of consecutive identical integers in array column

Compute maximum number of consecutive identical integers in array column Question: Consider the following: df = spark.createDataFrame([ [0, [1, 1, 4, 4, 4]], [1, [3, 2, 2, -4]], [2, [1, 1, 5, 5]], [3, [-1, -9, -9, -9, -9]]] , [‘id’, ‘array_col’] ) df.show() ”’ +—+——————–+ | id| array_col| +—+——————–+ | 0| [1, 1, 4, …

Total answers: 2

Django: aggregate django fields to avoid N + 1 problem

Django: aggregate django fields to avoid N + 1 problem Question: I have 3 tables/classes that are relevant to each other: CourseStudent – represents Student signed up to the course Presence – represents the attendance list of the CourseStudent CourseStudentPayment – represents the payments list for CourseStudent In the code it looks like this: class …

Total answers: 1

How to use for loop to run sql query in python

How to use for loop to run sql query in python Question: I have 100 records in table A, I only list 4 here but please use loop to solve this question A = [‘A001’, ‘B001′,’C001′,’Bdd’,’djd.djsx’] AB = pd.DataFrame(A, columns = [‘app_name’]) AB app_name 0 A001 1 B001 2 C001 3 Bdd 4 djd.djsx I …

Total answers: 2

I created a table and I'm trying to modify it but I get this error

I created a table and I'm trying to modify it but I get this error Question: I started tody with Python SQL Database conexion (or in general python databse collection i guess) and I was following a tutorial on youtube about how to create and modify the table, but at the moment when I tried …

Total answers: 1

PySide6: How to clear the values of all QPlainTextEdit and QComboBox elements after inserting data into a database?

PySide6: How to clear the values of all QPlainTextEdit and QComboBox elements after inserting data into a database? Question: Hy, i want to clear all qtextedit,qcombobox etc.., when a product is inserted in database,but i dont know, how to do it. Right now this is my function def commit(self): self.inserebd() tree_data=self.dadostree() self.contarserie() sql = """INSERT …

Total answers: 1

SQL INSERT but increment ID if exist without having to do separate SELECT query

SQL INSERT but increment ID if exist without having to do separate SELECT query Question: I have a table with Primary Key on two columns: ID (Users ID) and SQ (Sequence, this starts at 1 and increments +1 for each ID). A user should not have multiple instances of the same sequence #. Here is …

Total answers: 2

Trying to use Python variable names in psycopg2 queries

Trying to use Python variable names in psycopg2 queries Question: I am writing part of a Python program where I query a PostgreSQL table called stockNames and use the results to print information based on user input. stockNames has the following layout: company stockTicker industry Starbucks SBUX Food/Beverage … I also have a series of …

Total answers: 1

Can't write to file in Google Cloud

Can't write to file in Google Cloud Question: Currently, I have an SQL Database that I wish to edit locally. This is for a flask app made in python 3, using sqlite3. con = sqlite3.connect(‘Database/accounts.db’) cur = con.cursor() cur.execute(f"INSERT INTO Requests (Type, Argument, Priority, Time) VALUES (‘{a}’,'{b}’,{c},'{d}’)") con.commit() Except I keep getting the error: attempt …

Total answers: 2