0

I'm trying to use the scrapy pipeline to store its data in a sqlite3 database here is the little part that trows a OperationalError: near "Transaction": syntax error

def createResidentialTable(self):
    self.cur.execute("""CREATE TABLE IF NOT EXISTS Residential
        (Id INT PRIMARY KEY NOT NULL, Transaction TEXT, Location TEXT, Price REAL)""")

My debugging so far, if i remove the Transaction TEXT & Location TEXT & Price Real from the creating tables my spider runs again. So i'm assuming there is something wrong with my listing of the tables.

Have looked trough some code examples and the official sqlite3 documentation and they list it as followed :

Create table

c.execute('''CREATE TABLE stocks
             (date text, trans text, symbol text, qty real, price real)''')

Any thoughts or suggestions?

1 Answer 1

1

Transaction is a reserved keyword which you are not allowed to use as an identifier. Just use something other than Transaction as an identifier.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you this has been haunting me for a few days now :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.