Results 1 to 3 of 3

Thread: Segmentation fault when importing data from csv to sqllite database

  1. #1
    Join Date
    Feb 2011
    Posts
    64
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Segmentation fault when importing data from csv to sqllite database

    I am trying to insert big csv file(about ~35Mb) into sqlite database. So, when ever I press processButton I got segmentation fault, I can't figure out the cause of error.
    CSV format:
    xxxx, xxxxx, xxxxx, xxxxx with out double quote.
    Anu.zip

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Segmentation fault when importing data from csv to sqllite database

    I cannot reproduce the error with simple valid input. Check your input for lines with fewer than four columns especially the last/blank lines: your code assumes at least four columns in the input. Run the program in a debugger and determine where the error is originating.

    You should not build SQL statements as strings; they are prone to error, open to exploitation, and hard to maintain. Prepare a query and using bindValue() (See Approaches to Binding Values.

  3. #3
    Join Date
    Feb 2011
    Posts
    64
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Segmentation fault when importing data from csv to sqllite database

    I found the csv file I tried to import have some blank lines and line more then four columns. There is also another method to import csv data to sqlite database via sqlite shell:
    sqlite3 test.db
    sqlite>.mode csv
    sqlite>.import file.csv TableToInsertTo
    TableToInsertTo should have the some number of columns, like file.csv have. And that is how I figure my csv not correctly structured.

Similar Threads

  1. segmentation fault
    By navid in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2009, 11:40
  2. Segmentation fault
    By Schimanski in forum Qt Programming
    Replies: 20
    Last Post: 31st August 2009, 16:26
  3. segmentation fault
    By dreamer in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2008, 07:48
  4. Segmentation Fault
    By merry in forum General Programming
    Replies: 4
    Last Post: 12th March 2007, 04:08
  5. (Another) segmentation fault
    By Lebowski in forum Qt Programming
    Replies: 27
    Last Post: 6th April 2006, 06:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.