Skip to content

Tag: sqlite

Can repeating query be saved?

In my Python / Sqlite program, I am running queries like this So the “basic” query is the same, and the rows Sqlite gathers are the same, but because of the different grouping , I have to run the same query multiple times. I wonder if there is a way to achieve the same output more effectively, ie.…

sqlite3.OperationalError:: syntax error when trying to UPDATE

I have been trying to update some values in a sqlite3 table but I am having loads of problems with the `sqlite3.OperationalError: near “GROUP”: syntax error. I have been following the documentation but I am not been very successful to correct the error. What I am trying to do is to find the all_nu…

passing table name to pipeline scrapy python

I have different spiders that scrape similar values and I want to store the scraped values in different slite3 tables. I can do this by using a different pipeline for each spider but, since the only thing that changes is the table name, would it be possible to pass somehow the table name from the spider to th…

How to loop thorough rows of each column in a table?

I am trying to write a small program to transform a database. It is an SQLite database, and I am using Python. I am experiencing a problem where the query I’m writing doesn’t seem to work properly: For some reason, what’s printed here is just a list on the column name repeated a number of ti…

In python, can we set table name as a variable using Sqlite3?

For example: This way I can change the value of a and process the database with a function in python. But how can I do something similar with Table names? This way I can use one function to handle different tables. Answer Parsing in table names is made to not work intentionally, since dynamically using table …

Trouble With SQL Query in Python

Hello I’m getting an error: near “join”: syntax error. Is there an obvious issue with this that I’m not picking up on? I’ve changed names in the query but I’ve gone over and checked for spelling errors already. Answer In SQL, the order of clauses is SELECT, FROM, JOIN, WHER…

UPDATE SQLite database from Python not working as expected

I want to perform an UPDATE? on a SQLite database from Python (2.7). This is the table` and this is how I want to insert rows However, when I do a SELECT * FROM foo it the result set is zero rows.. There is not data in there. Why? Answer It sounds like you want to insert here, not update: