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.…
Tag: sqlite
sqlite3.DatabaseError: malformed database schema (?)
I executed the python file in the first try & it worked. But when I included the code “IF NOT EXISTS” in the line cur.execute(“CREATE TABLE IF NOT EXISTS store (item TEXT, quantity INTEGER, price REAL)”)& cur.execute(“INSERT INTO store VALUES (‘Wine Glass,8,10.5R…
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…
SQLite3 Integrity Error When Running “createsuperuser”
I am trying to extend the default Django User model by linking to it through a OneToOneField. I successfully migrated the changes and registered my Profile model inside admin.py, however, when I try to run the command python manage.py createsuperuser and fill in the information I get an Integrity Error. I kno…
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…
SQL 3 query Table 2 column value in Table 1 in condition
I having an issue trying to form query for the question below: SQL statement to find all table A which have a value of table B appearing more than 1 after compiling the cur fetch nothing. so my did form the query correctly, please help thanks Answer
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: