Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there any way to copy table from database to another one?
QtWS25 Last Chance

Is there any way to copy table from database to another one?

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 7.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mismail
    wrote on 29 Nov 2011, 00:08 last edited by
    #1

    Hi everybody,

    I am trying to copy one table from access database to a sqlite database.
    Is there any way to do that?
    I appreciate your suggestions.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on 29 Nov 2011, 07:28 last edited by
      #2

      I don't think there is something more convenient than a simple loop when it comes to copy data between different DBMSs. If this is just a one-time transfer and needs not to be done programmatically I would go for an CVS or SQL export and import.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fluca1978
        wrote on 29 Nov 2011, 07:32 last edited by
        #3

        My suggestion is to avoid it at all in your application, unless you have a very good reason for that. Databases have very good tools for exporting and importing data, that are usually much more efficient than looping across data. Then it depends on which database you are starting from. Many enterprise database (Oracle, PostgreSQL) provides foreign tables, that are the implementation of the sql med, and offer you a way to access tables in other database so that migrating data becomes no more than a SELECT INTO.
        If you are really constrained to do the migration within your application than you have to open two different connections, read from the source, insert in the destination and loop until source has no more data.

        Ops...sorry I read too late you were talking about MS Access as source database....then I suspect you will have to loop or use a CVS intermediate format,

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mismail
          wrote on 29 Nov 2011, 10:41 last edited by
          #4

          Well, it seems that there is no way to copy the data except the loop way.
          BTW, Is there any way to know the types of the fields in the source database?
          Thank you very much

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fluca1978
            wrote on 29 Nov 2011, 11:23 last edited by
            #5

            Well you can inspect fields using "QSqlField":http://doc.qt.nokia.com/latest/qsqlfield.html or the "record method on QSqlDatabase":http://doc.qt.nokia.com/latest/qsqldatabase.html#record to do table introspection.

            [EDIT: fixed link, volker]

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on 29 Nov 2011, 12:26 last edited by
              #6

              Do you really need this in your own application? I know there are third party applications that you can use for this conversion. Do you want to create such a converter yourself, or is it ok to use a third party application?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mismail
                wrote on 29 Nov 2011, 13:14 last edited by
                #7

                No, we need to convert those database in our application.
                because the current version of our application uses the access database , we want to upgrade our application and use the sqlite in it.
                also we want the end user just use the new version to convert the databases he already has. not downloading it again from our server.
                we have more than 5000 database (books).

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on 29 Nov 2011, 13:39 last edited by
                  #8

                  Well, if it is an application specific database, I think that you know better than anyone how to transfer the data and the structure. That is going to work better than any generic approach that we can come up with. However, it seems to me that you only need to do a one-time conversion of everything, right?

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    fluca1978
                    wrote on 29 Nov 2011, 14:00 last edited by
                    #9

                    Sounds to me like you need a one-shot converter from access to sqllite. But you should also have a well defined structure in access tha you need to translate in a well defined structure into sqllite, so a script or something alike to call as an external program could do the trick. And you will not need to do introspection against the original database structure.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mismail
                      wrote on 29 Nov 2011, 14:27 last edited by
                      #10

                      Andre,
                      Yes it is one time conversion.

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        andre
                        wrote on 29 Nov 2011, 14:39 last edited by
                        #11

                        Then, why do you need it in your own application? In that case, any MDB to SQLite conversion will do, right? Even better if you can script it.

                        1 Reply Last reply
                        0

                        2/11

                        29 Nov 2011, 07:28

                        topic:navigator.unread, 9
                        • Login

                        • Login or register to search.
                        2 out of 11
                        • First post
                          2/11
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved