Python Forum
Help With Python SQLite Error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help With Python SQLite Error
#1
Hello,

I created this table:
import sqlite3

#Create a database (inventory.db)
connection = sqlite3.connect("inventory.db")
cursor = connection.cursor()

cursor.execute('''CREATE TABLE Items
        (ID INT PRIMARY KEY    NOT NULL,
        NAME           TEXT    NOT NULL,
        Image          BLOB,
        Quantity       TEXT    NOT NULL,
        Price          DOUBLE  NOT NULL,
        Sell Price     DOUBLE,
        Location       TEXT    NOT NULL,
        Description    TEXT,
        Category       TEXT,
        Length(Ft)     INT,
        Brightness     TEXT,
        Rating         TEXT,
        Torque         TEXT,  
        Date Updated   timestamp);''')

#Commit the changes
connection.commit()
#Close the connection
connection.close() 
And when I run the script I get:
Error:
Traceback (most recent call last): File "SQLite_Database.py", line 21, in <module> Date Updated timestamp);''') sqlite3.OperationalError: near "(": syntax error
This is starting to drive me mad because I can't seem to figure it out

Any help would be greatly appreciated.

Thanks.

P.S
Also, I do happen to have another question. How would I go about displaying the records in the database (once I add some)?
I know I'll need a for loop and a select statement but I don't know how to mix them together to get it to work.
(Also any good tutorials for SQLite with python that you can point me to would be appreciated as well. I'm familiar with MySQl but it's been a while. I don't know if SQLite is much different.)
Reply


Messages In This Thread
Help With Python SQLite Error - by Extra - Apr-30-2022, 12:16 AM
RE: Help With Python SQLite Error - by Extra - Apr-30-2022, 01:01 AM
RE: Help With Python SQLite Error - by deanhystad - Apr-30-2022, 03:01 AM
RE: Help With Python SQLite Error - by ibreeden - May-01-2022, 09:09 AM
RE: Help With Python SQLite Error - by Extra - May-02-2022, 11:08 PM
RE: Help With Python SQLite Error - by menator01 - May-03-2022, 12:42 AM
RE: Help With Python SQLite Error - by Extra - May-03-2022, 10:47 PM
RE: Help With Python SQLite Error - by ibreeden - May-04-2022, 07:18 AM
RE: Help With Python SQLite Error - by Extra - May-04-2022, 11:42 PM
RE: Help With Python SQLite Error - by menator01 - May-04-2022, 07:19 AM
RE: Help With Python SQLite Error - by Extra - May-04-2022, 11:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  need help with data analysing with python and sqlite Hardcool 2 1,184 Jan-30-2024, 06:49 AM
Last Post: Athi
  python sqlite autoincrement in primary column janeik 6 3,456 Aug-13-2023, 11:22 AM
Last Post: janeik
  Help with subtracting values using SQLite & Python Extra 10 5,791 May-10-2022, 08:36 AM
Last Post: ibreeden
  [Solved]Help with search statement-SQLite & Python Extra 1 2,112 May-06-2022, 07:38 PM
Last Post: Extra
  Python Sqlite georgebijum 0 1,713 May-04-2022, 10:12 AM
Last Post: georgebijum
  Error while transferring data from sqlite to elasticsearch - please help! ps96068 1 3,843 Jun-12-2021, 09:24 AM
Last Post: ibreeden
  SQLite Unique constraint failed error djwilson0495 3 17,364 Aug-14-2020, 05:23 PM
Last Post: ndc85430
  Importing data from a text file into an SQLite database with Python macieju1974 7 6,610 Jun-29-2020, 08:51 PM
Last Post: buran
  how to use items combobox in table name sqlite in python hampython 1 3,630 May-24-2020, 02:17 AM
Last Post: Larz60+
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 19,876 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020