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?

asked Jul 31, 2016 at 10:28

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.

answered Jul 31, 2016 at 10:31
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.