sqlite

Read lines from .txt file into sql query

Read lines from .txt file into sql query Question: I want to run a .txt file line for line through an SQL query. The .txt file consists of songtitles that may or may not exist in the database. If there is more than one option that fits the songtitle in the database a selection menu …

Total answers: 1

Copying a table from an in-memory database to a on-disk database in sqlite3

Copying a table from an in-memory database to a on-disk database in sqlite3 Question: I want to copy one specific table from an in-memory sqlite database, using Python (3.9). Looking in the documentation, I should be able to simply attach the in-memory database to the file database, however while attaching throws no error, when I …

Total answers: 1

Python Sqlite and Excel output with headers and Row ID

Python Sqlite and Excel output with headers and Row ID Question: Please help to find correct solution from "simple to customize in future" point of view. I have SQLite table and very big select. After this select I got 5 column and any rows. I want to export this data to Special Excel file and …

Total answers: 1

how to send parameters with f-Strings in a sqllite query python

how to send parameters with f-Strings in a sqllite query python Question: how can i send a parameter to a query this is my code import pandas as pd import sqlite3 def query_brand(filter): sql_query = pd.read_sql(f’SELECT * FROM ps_lss_brands WHERE label = {filter}’, self.conn_brand) df = pd.DataFrame(sql_query, columns = [‘id_brand’, ‘label’]) # print(df["id_brand"][0]) print(df) query_brand("ACURA") …

Total answers: 1

Create ranking within set of rows resulting from GROUP BY

Create ranking within set of rows resulting from GROUP BY Question: I have the following table CREATE TABLE "results" ( "player" INTEGER, "tournament" INTEGER, "year" INTEGER, "course" INTEGER, "round" INTEGER, "score" INTEGER, ); With the following data sample for a single tournament / year / round-combination. 1 33 2016 895 1 20 2 33 2016 …

Total answers: 1

Iterator should return strings, not bytes (the file should be opened in text mode)

Iterator should return strings, not bytes (the file should be opened in text mode) Question: List item this is my code.. def import_excel(request): if request.method == ‘POST’: person_resource = PersonResource() dataset = Dataset() new_person = request.FILES[‘myfile’] if not new_person.name.endswith(‘csv’): messages.info(request,’Wrong format’) return render(request,’upload.html’) imported_data = dataset.load(new_person.read(),format=’csv’) for data in imported_data: value = Person( data[0], data[1], …

Total answers: 1

how to update sqlite python table Based on match between another table

how to update sqlite python table Based on match between another table Question: I tried to use the following code but it is giving errors: import sqlite3 conn = sqlite3.connect(‘stock.db’) cursor = conn.cursor() conn.execute("UPDATE COMSEC_STOCK SET COMSEC_STOCK.quantity = COMSEC_STOCK.quantity -1 FROM COMSEC_STOCK, Comsec_Out_Temp WHERE COMSEC_STOCK.product_id = Comsec_Out_Temp.product_id") cursor.close() conn.commit() Asked By: user21030066 || Source Answers: …

Total answers: 1

Is there a way to select all rows created today(current date), if that column has time format date and time?

Is there a way to select all rows created today(current date), if that column has time format date and time? Question: If I have a table that contains: table_id id_from_other_table date_time_when_this_row_was_added [(1, 200, ‘2023-01-06 08-11-21’)] [(2, 200, ‘2023-01-07 07-21-21’)] [(3, 200, ‘2023-01-07 08-10-10′)] Can I get all the rows that were created at today’s date …

Total answers: 1

my Flask python server still running after shutdown

my Flask python server still running after shutdown Question: I Tried running a new http://127.0.0.1:5000/ local server and the old one was still showing after I stopped it and hard reload. my Chorme still show pervious server results after I’ve ended the program and when I ran another program it shows same result as old …

Total answers: 1

How to create a function for multiple queries that accepts zero, one or more placeholders?

How to create a function for multiple queries that accepts zero, one or more placeholders? Question: Because I have multiple queries to different tables, with different placeholders, I would like to create a function for this. But I can’t decide on parameters of this function For example def function_q(query, placeholder): cursor.execute(query, (placeholder,)) return cursor.fetchall() But …

Total answers: 1