udacity/APIs

Lessson-4-Quiz Mom and BOB sqlite3.ProgrammingError

Closed this issue · 2 comments

i am always having sql thread error when i execute bagel_tester.py or any previouse testers

ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 139715948619520 and this is thread id 139715939702528 [SQL: u'SELECT user.id AS user_id, user.username AS user_username, user.password_hash AS user_password_hash \nFROM user \nWHERE user.username = ?\n LIMIT ? OFFSET ?'] [parameters: [{}]] (Background on this error at: http://sqlalche.me/e/f405)

i could solve this issue by adding time.sleep(3) between each try and the other

fjp commented

SQLite by default prohibits the usage of a single connection in more than one thread.
just add connect_args={'check_same_thread': False} parameter to your engine variable like

engine = create_engine(''sqlite:///usersWithOAuth.db', connect_args={'check_same_thread': False}, echo=True)

Source

Yeah @fjp
that works well