Results 1 to 14 of 14

Thread: access SQlite from Qt (Windows & Linux)

  1. #1
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default access SQlite from Qt (Windows & Linux)

    Hi all,

    I m using Qt 4.4.3 on Windoes XP.
    I have developed an application ,now I want to use SQLite database fro storing some fields.

    Can anyone help me out in things like

    1) from where to download SQLite .
    2) How to access SQLite database from Qt.

    3) The final application would be ported to Linux,so tell me which database to be used so that it would be compatible with Linux also.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    Qt already supports SQLite "from the box" and this driver available by default when Qt has been built.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    But how to start building database,from where to download SQLite>?

    "from the box" ????????? (dint understand)

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    all what you need it's a build Qt with SQLite suppport, SQLite driver are located in QTDIR/src/3rdparty/sqlite.
    "from the box" -- by default.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    I m still not getting how would I create my database.....

    In the path you told there are 3 files

    1)shell.c
    2)sqlite3.c
    3)sqlite.h


    How to use these files for creating my database??

    Or is there any other GUI provided for creating database?????

  6. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    there is no GUI in sqlite+Qt world.. (thats why its "lite").. you have to code in everything...
    first you need to configure Qt with sqlite support (see configure help for this).
    then learn the QtSql module.. (its a matter of just how fast u can read the docs).
    then create teh database and/or read it.(in c++/Qt code).

  7. #7
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    sigh, to create a database you need to specify a database name using QSqlDatabase::setDatabaseName, a database file will be created in current directory and its name will be equal to database name.
    PS. take a look into QTDIR/examples/sql/connection.h, if you change
    Qt Code:
    1. db.setDatabaseName(":memory:");
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. db.setDatabaseName("mydatabase");
    To copy to clipboard, switch view to plain text mode 
    then all data will be kept in a file insted of RAM.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. #8
    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: access SQlite from Qt (Windows & Linux)

    You can get a basic command line tool to manipulate Sqlite databases from the Sqlite site:
    http://sqlite.org
    This tool can be very useful when you first start an Sqlite database project.

    You can also create and manipulate databases within the code of your Qt application. As others have pointed out you only need to use a Qt library built with Sqlite support (e.g. any of the Qt Creator SDK downloads).

  9. #9
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    If you want a "graphical interface" can also use this one.

    SQLiteman

    Made with Qt, so works in Linux/Unix, Win, Mac...

  10. The following user says thank you to jpujolf for this useful post:

    SunnySan (22nd July 2009)

  11. #10
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    I had installed SQLIteman.

    created one database and one table in it.

    Nos how to connect to this database from Qt?????

  12. #11
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    Take a look at this

    Also you can look at here or here

    And from now on, before asking so basic things :

    - Read at least Qt's documentation here
    - Google a little or search Qt centre ( I've done a simple search : sqlite connect and got me 24 results )

    And please, please, please : don't open TWO threads asking the same and don't ignore the answers people gently gives to you ( as here )

    Thanks.

  13. #12
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    When I created a new database in sQLiteman.then first it asked me to store one file .

    I hav attached that file herewith.......

    Now my question is ,how my qt application would recognize where my database is located...

    Do I hav to place this at path executable resides.....
    Attached Files Attached Files

  14. #13
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    please man... take a look at qtassistant... search for qt sql module... its very easy task

  15. #14
    Join Date
    Jul 2008
    Posts
    69
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: access SQlite from Qt (Windows & Linux)

    Quote Originally Posted by jpujolf View Post
    If you want a "graphical interface" can also use this one.

    SQLiteman

    Made with Qt, so works in Linux/Unix, Win, Mac...
    thanks for the link Sqliteman is a great open source SQL application.

Similar Threads

  1. Deployment Procedure On Windows On Linux and Windows
    By Harshith J.V. in forum Installation and Deployment
    Replies: 4
    Last Post: 9th July 2009, 11:27
  2. Replies: 2
    Last Post: 4th June 2009, 16:09
  3. Replies: 5
    Last Post: 15th January 2009, 09:03
  4. QPalette works differently on windows and linux
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 6th March 2008, 07:27
  5. Replies: 4
    Last Post: 12th January 2006, 04:16

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.