#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    North West England
    Posts
    6
    Rep Power
    0

    Python & sqlite3 Insert woes


    Hi all,

    I'm having a problem inserting a record into a sqlite3 table. The insert statement works fine if I execute it as pure SQL in sqlite at the CLI, but from Python it is causing me a headache!

    My code is as such:

    Code:
    connection = sqlite3.connect(SQL_FILE)
    
    	cur = connection.cursor()
    	cur.execute("INSERT INTO outofmemoryexception (oom_id, oom_date, oom_time) VALUES(8, '2013-07-03', '16:12:45')")
    	cur.close()
    Like I said, if I execute: INSERT INTO outofmemoryexception (oom_id, oom_date, oom_time) VALUES(8, '2013-07-03', '16:12:45') as pure SQL it works, so I really don't understand what is happening?

    I can access the database fine from within Python, I can select from the tables and get valid data back, but I don't quite understand why this is being such a pain?

    Kind Regards,
    Morrolan
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Usually Japan when not on contract
    Posts
    240
    Rep Power
    12
    Hmmm... works fine for me if I've just created the db file from within the program to begin with.

    Does the process have write permission on the db file? Are you getting an error message?

IMN logo majestic logo threadwatch logo seochat tools logo