From canismajorwuff at gmail.com Sat Dec 8 11:24:16 2012 From: canismajorwuff at gmail.com (CanisMajorWuff) Date: Sat Dec 8 14:20:13 2012 Subject: [odb-users] odb::sqlite::database lining error Message-ID: <50C369B0.8070302@gmail.com> Hi, I am on Windows 7 using mingw64 (ruben build). I compiled libodb and libodb-sqlite packages. I wrote a small test application to test odb. The compilation was successfully completed. But I have linking errors. Here it is linking command: ['d:\\mingw\\bin\\g++.exe', '-Wl,--enable-auto-import', '-Wl,--enable-auto-import', 'src\\Main.cpp.1.o', '-o', 'e :\\Documents\\documents\\C++Projects\\orm\\build\\src\\ormtest.exe', '-Wl,-Bstatic', '-LD:/odb/libodb/lib', '-LD: /odb/sqlite/lib', '-LD:/sqlite3', '-lsqlite3', '-lodb', '-lodb-sqlite', '-Wl,-Bdynamic'] The errors: src\Main.cpp.1.o:Main.cpp:(.text.startup+0xe4): undefined reference to `__imp__ZN3odb6sqlite8databaseC1ERiPPcbibR KSsNS_7details12transfer_ptrINS0_18connection_factoryEEE' src\Main.cpp.1.o:Main.cpp:(.text.startup+0x125): undefined reference to `__imp__ZN3odb6sqlite8databaseD1Ev' src\Main.cpp.1.o:Main.cpp:(.text.startup+0x1a1): undefined reference to `__imp__ZN3odb6sqlite8databaseD1Ev' d:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/bin/ld.exe: src\Main.cpp.1.o: bad reloc address 0x0 in section `.pdata.startup' d:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: In valid operation collect2.exe: error: ld returned 1 exit status Please, help me to rid of this error. From boris at codesynthesis.com Sun Dec 9 05:36:08 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Dec 9 04:52:27 2012 Subject: [odb-users] odb::sqlite::database lining error In-Reply-To: <50C369B0.8070302@gmail.com> References: <50C369B0.8070302@gmail.com> Message-ID: Hi, CanisMajorWuff writes: > ['d:\\mingw\\bin\\g++.exe', '-Wl,--enable-auto-import', > '-Wl,--enable-auto-import', 'src\\Main.cpp.1.o', '-o', 'e > :\\Documents\\documents\\C++Projects\\orm\\build\\src\\ormtest.exe', > '-Wl,-Bstatic', '-LD:/odb/libodb/lib', '-LD: > /odb/sqlite/lib', '-LD:/sqlite3', '-lsqlite3', '-lodb', '-lodb-sqlite', > '-Wl,-Bdynamic'] > > src\Main.cpp.1.o:Main.cpp:(.text.startup+0xe4): undefined reference to > `__imp__ZN3odb6sqlite8databaseC1ERiPPcbibR I believe what happens is you are linking to static libodb and libodb-sqlite (the -Wl,-Bstatic option) while these libraries were built as DLLs (the __imp__ prefix in the unresolved symbol suggest that). So you can try two things: 1. Remove the -Wl,-Bstatic and -Wl,-Bdynamic options. 2. Or, rebuild libodb and libodb-sqlite as static: ./configure --disable-shared Boris From duhai_lee at qq.com Sun Dec 9 22:36:02 2012 From: duhai_lee at qq.com (=?utf-8?B?SnVzdGxpdmU=?=) Date: Mon Dec 10 09:10:48 2012 Subject: [odb-users] How to Modify ODB template by generate code Message-ID:
Hi,
    I used odb version is 2.0.1. My compiler is vc2003, OS is windows 7. Generate code by ODB command, compily it, then make a mistake...

I must modify it like this:

 result< access::object_traits< ::OilField >::object_type >
  access::object_traits< ::OilField >::
  query (database&, const query_base_type& q)
  {
    //using namespace mysql;   // comment this line..
    using odb::details::shared;
    using odb::details::shared_ptr;

    mysql::connection& conn (
      mysql::transaction::current ().connection ());

    statements_type& sts (
      conn.statement_cache ().find_object<object_type> ());

    image_type& im (sts.image ());
    mysql::binding& imb (sts.select_image_binding ());  // add mysql:: namespace

    if (im.version != sts.select_image_version () ||
        imb.version == 0)
    {
      bind (imb.bind, im, mysql::statement_select);  // add mysql:: namespace
      sts.select_image_version (im.version);
      imb.version++;
    }

    shared_ptr<mysql::select_statement> st (   // add mysql:: namespace
      new (shared) mysql::select_statement (     // add mysql:: namespace
        sts.connection (),
        query_statement + q.clause (),
        q.parameters_binding (),
        imb));

    st->execute ();

    shared_ptr< odb::object_result_impl<object_type> > r (
      new (shared) mysql::object_result_impl<object_type> (
        q, st, sts));

    return result<object_type> (r);
  }

then,  it works.
of course, if I would't modify it, it works good on vs2010. 

so, I hope I can modify template of generating code .  else I modify it what generated code every time I modify my entity class. 
but I can't found that to change the template. It's just a odb.exe. 

thanks..


From boris at codesynthesis.com Mon Dec 10 10:06:31 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 10 09:22:30 2012 Subject: [odb-users] How to Modify ODB template by generate code In-Reply-To: References: Message-ID: Hi, Justlive writes: > My compiler is vc2003, OS is windows 7. Generate code by ODB command, > compily it, then make a mistake... No, there is no mistake in the generated code. VC++ 2003 is very old and buggy and therefore not supported. Even if you apply your workarounds, I wouldn't be surprised that more things will break down the road. > but I can't found that to change the template There is no "template". The generated code is too complex to use some sort of a template system. The only way to customize the generated code is by modifying the ODB compiler source code. However, it will be much easier to just upgrade to a more recent version of VC++. As you have said, everything works just fine with VC++ 2010 (as with 2008 and 2012). Boris From boris at codesynthesis.com Mon Dec 10 10:14:11 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 10 09:30:08 2012 Subject: [odb-users] odb::sqlite::database lining error In-Reply-To: <50C50D62.7060105@gmail.com> References: <50C369B0.8070302@gmail.com> <50C50D62.7060105@gmail.com> Message-ID: Hi, In the future please keep your replies CC'ed to the odb-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml CanisMajorWuff writes: > I did what you said. > 1. the same result. Ok, so the DLL approach doesn't work for some reason on your MinGW setup (not an unusual thing to happen). > 2. I rebuilt libodb and libodb-sqlite and now I have the following errors > > src\Well-odb.cxx.1.o:Well-odb.cxx:(.text+0x2e): undefined reference to > `__imp__ZN3odb7details11shared_base17_dec > _ref_callbackEv' Hm, for some reason your code is still referencing the symbols as if they were in a DLL. Have you recompiled your code (i.e., Well-odb.cxx) after reconfiguring and rebuilding libodb and libodb-sqlite? Try these steps to make sure: 1. Remove libodb and libodb-sqlite builddirectories and unpack fresh source code from the archives. 2. Configure with --disable-shared and build. 3. Clean your project (i.e., remove all the *.o files) and recompile. > BTW, I added libodb.dll to the path. Now, after rebuilding I don't have > dll at all. Right, because now you are building static libraries. Boris From Davide.Anastasia at qualitycapital.com Mon Dec 10 12:35:56 2012 From: Davide.Anastasia at qualitycapital.com (Davide Anastasia) Date: Mon Dec 10 12:27:37 2012 Subject: [odb-users] Derivation and empty classes Message-ID: <6989CEDF160F9A42A3F5FF832CBAA72C262673@exbe19.nasstar-t1.net> Hi, I am trying to create a class hierarchy to be mapped into ODB objects using polymorphic derivation. However, many of my derived classes (pretty much all, except 2) are empty. Is there a way, in such a scenario, to avoid the generation of a table that contains only a member (the id a foreign key) that refers to the table of the base class? Best, Davide Anastasia Analyst, Research & Development Quality Capital Management Ltd. QCM House * Horizon Business Village No. 1 Brooklands Road Weybridge * Surrey KT13 0TJ United Kingdom Tel: +44 (0) 1932 334 400 Fax: +44 (0) 1932 334 415 Email: Davide.Anastasia@QualityCapital.com www.qualitycapital.com ________________________________ This email and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Quality Capital Management Ltd. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, printing, forwarding or copying of this email is strictly prohibited. Please contact the sender if you have received this email in error. You should also be aware that emails are susceptible to interference and you should not assume that the contents of this email originated from the sender above or that they have been accurately reproduced in their original form. Quality Capital Management Ltd is authorised and regulated by the Financial Services Authority in the UK and is a member of the National Futures Association in the US. ________________________________ From reza.jahanbakhshi at gmail.com Tue Dec 11 08:47:39 2012 From: reza.jahanbakhshi at gmail.com (Reza Jahanbakhshi) Date: Tue Dec 11 08:37:51 2012 Subject: [odb-users] Concatenation of columns Message-ID: Hi, Concatenation syntax varies from one DBMS to another. Is there any facility in ODB query language to do this in a cross DBMS manner? I think overloading of operator | could be a good candidate. -- SQL Server / Microsoft Access SELECT FirstName + ' ' + LastName As FullName FROM Customers -- Oracle SELECT FirstName || ' ' || LastName As FullName FROM Customers -- MySQL SELECT CONCAT(FirstName, ' ', LastName) As FullName FROM Customers From boris at codesynthesis.com Tue Dec 11 09:41:08 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 11 08:56:48 2012 Subject: [odb-users] Derivation and empty classes In-Reply-To: <6989CEDF160F9A42A3F5FF832CBAA72C262673@exbe19.nasstar-t1.net> References: <6989CEDF160F9A42A3F5FF832CBAA72C262673@exbe19.nasstar-t1.net> Message-ID: Hi Davide, Davide Anastasia writes: > I am trying to create a class hierarchy to be mapped into ODB objects > using polymorphic derivation. However, many of my derived classes > (pretty much all, except 2) are empty. Is there a way, in such a > scenario, to avoid the generation of a table that contains only a member > (the id a foreign key) that refers to the table of the base class? No, that table is actually necessary for some functionality. Consider, for example, a query that specifies a base class. Such a query should return all the objects that are of the base class plus of any derived class. ODB uses this (in your case empty) table to get that list. Also, it seems strange to store in the database derived objects that don't have any extra data. Boris From boris at codesynthesis.com Tue Dec 11 09:45:25 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 11 09:01:04 2012 Subject: [odb-users] Concatenation of columns In-Reply-To: References: Message-ID: Hi Reza, Reza Jahanbakhshi writes: > Concatenation syntax varies from one DBMS to another. Is there any facility > in ODB query language to do this in a cross DBMS manner? No, there is no such support. I am also not sure it is a good idea to do things like this on the database side. Generally, you would want to do as much processing as possible on the client to conserve database server resources. So unless I am missing something in your use-case, it is probably a better idea to return the columns as separate values and concatenate them in C++. Boris From boris at codesynthesis.com Wed Dec 12 08:46:57 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Dec 12 08:02:18 2012 Subject: [odb-users] Concatenation of columns In-Reply-To: References: Message-ID: Hi Reza, In the future please keep your replies always CC'ed to the odb-users mailing list as discussed in the posting guidelines: http://www.codesynthesis.com/support/posting-guidelines.xhtml Reza Jahanbakhshi writes: > I understand your concern about database server resources. Here is my > scenario. I have a table which three of its columns each represent a > meaningful entity and concatenated together represent a new entity. I need > to use this new entity in queries specially in WHERE LIKE clause because I > need to filter on that. I think it's not efficient to fetch and iterate the > whole table over network to find the rows I need. Also I think database > engines can do this much better in terms of at least less memory usage and > network traffic. Please tell me if I'm wrong and what is your suggestion > for this kind of use-cases? No, fetching all the rows and then doing the filtering on the client side is definitely not the way to do it. The best way would be to make concatenation unnecessary. That is, re-implement your LIKE clause to use individual columns instead. But I agree, this may not always be possible or convenient and sometimes it might be just simpler to let the database do the work. I am, however, still not convinced that we should provide wrappers for operations like concatenation in ODB. Once we start on this path, it will be hard to stop until we wrap pretty much all the operators, and that's going to be a lot of them. Also, this "computation on the database" approach really goes against the ODB (and ORM in general) philosophy of treating the database as, well, a database rather than an application server. I also realize that the real world is more complex and often the easier or, in fact, the only practical way is to do some computation on the database side. For such cases, however, I think the native query support that ODB provides should be sufficient. Especially, since such usage almost always leads to tight dependence on a specific database system anyway. Having said that, nothing prevents you from writing a few simple wrappers that abstract away from specific databases, if you need to be portable. For example: #include #include #include // MySQL version. // template odb::mysql::query_base concat (const odb::mysql::query_column& x, const odb::mysql::query_column& y) { return "CONCAT(" + x + ",' '," + y + ")"; } // Oracle version. // template odb::oracle::query_base concat (const odb::oracle::query_column& x, const odb::oracle::query_column& y) { return x + "|| ' ' ||" + y; } // SQL Server version. // template odb::mssql::query_base concat (const odb::mssql::query_column& x, const odb::mssql::query_column& y) { return x + "+ ' ' +" + y; } And then, in your code: query q (concat (query::first, query::last) + "LIKE" + query::_val ("J% Doe")); Boris From boris at codesynthesis.com Wed Dec 12 09:11:19 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Dec 12 08:26:40 2012 Subject: [odb-users] ODB 2.2.0.a2 available Message-ID: Hi, The second alpha version for the upcoming ODB 2.2.0 is now available. The NEWS file entries so far are: * Multi-database support. It allows an application to simultaneously work with multiple database systems and comes in two flavors: static and dynamic. With static support the application uses the static database interfaces (that is, odb::::database instead of odb::database). With dynamic support the same application code can access multiple databases via a common interface. Dynamic multi-database supports also allows the application to dynamically load the database support code for individual databases if and when necessary. For more information, refer to Chapter 13, "Multi-Database Support" in the ODB manual. * Support for prepared queries. Prepared queries are a thin wrapper around the underlying database system's prepared statements functionality. They provide a way to perform potentially expensive query preparations tasks only once and then executing the query multiple time. For more information, refer to Section 4.5, "Prepared Queries" in the ODB manual as well as the 'prepared' example in the odb-examples package. * Support for automatically-derived SQL name (table, column, index, etc.) transformations. At the higher level, it is possible to assign prefixes and suffixes (--table-prefix, --{index,fkey,sequence}--suffix options) as well as to convert to upper or lower case (--sql-name-case option). At the lower level, it is possible to specify transformations as regular expressions (--{table,column,index,fkey,sequence,sql-name}-regex options). For more information, refer to the SQL NAME TRANSFORMATIONS section in the ODB compiler command line interface documentation (man pages). * New options, --export-symbol and --extern-symbol, allow DLL exporting of the generated database support code. * Support for early connection release. Now the database connection is released when commit()/rollback() is called rather than when the transaction instance goes out of scope. This pre-release is available from: http://www.codesynthesis.com/download/odb/pre-release/ The SHA1 sums for all the files in this pre-release are provided at the end of the email. Testing and feedback are much appreciated. Enjoy, Boris c0581df4019a27e5a4d346114bd564c8e59ca922 libodb-2.2.0.a2.tar.bz2 7993e786c0cba032cc18030240cdee15b29de2b5 libodb-2.2.0.a2.tar.gz 9461de7172500299f9ed98567968bd0049135b30 libodb-2.2.0.a2.zip 2c119c9e4ab9d5489992e4d29c99bdf039d73598 libodb-boost-2.2.0.a2.tar.bz2 ee14610ff551721ec2cb587b8c6a513567605234 libodb-boost-2.2.0.a2.tar.gz e882f933de1bae3da7aec8fe6f1467ccf995ad38 libodb-boost-2.2.0.a2.zip 5dba03d9f277bda8e49a3f8c65a47f107a43eb47 libodb-mssql-2.2.0.a2.tar.bz2 e0c7ae9b7d9c67d4b624ebadba302680dd0c8ac9 libodb-mssql-2.2.0.a2.tar.gz 5afa84fb5c6b7f18a29cdcc5aa626d9b88547231 libodb-mssql-2.2.0.a2.zip 3c4d1ac68aa1f7923389c26a1055251ffc6d117f libodb-mysql-2.2.0.a2.tar.bz2 ecce239ee1102dc2c29a8a3bf783441ad45388a4 libodb-mysql-2.2.0.a2.tar.gz b80036b03185fc463c5d8fee7d0ca6f62d9f98f6 libodb-mysql-2.2.0.a2.zip b41681fffc1dca03c3a85ae987becb603d2eea31 libodb-oracle-2.2.0.a2.tar.bz2 9ec3a59760e1f70cace428b3140046bd6a35975d libodb-oracle-2.2.0.a2.tar.gz 48e30eae7ac7079afcb4cf58e1ce1b9575646c03 libodb-oracle-2.2.0.a2.zip 8155a9e760c9cdf19ad8edd568c1618d322950bd libodb-pgsql-2.2.0.a2.tar.bz2 678a3d2389279b1ef8a132f01826c2df0d90a88b libodb-pgsql-2.2.0.a2.tar.gz a55bc9788a0094583351fa95df3c9abf8ab5472f libodb-pgsql-2.2.0.a2.zip 0c1e35cbdcbf188757cf32dfd67017fa6e868db7 libodb-qt-2.2.0.a2.tar.bz2 7adf167bc072d0e831fe19c1565a52803c56ac1a libodb-qt-2.2.0.a2.tar.gz 44768703a2bfc441939e06396841b1438c5d4008 libodb-qt-2.2.0.a2.zip da70ab050c598360019730e618bc1a7f2a80c3d7 libodb-sqlite-2.2.0.a2.tar.bz2 4b32ca7d617e6a52a29f37e66b4f46b621d53670 libodb-sqlite-2.2.0.a2.tar.gz 3b1d2f1e8f26706e59c74752fdd6718752e7984d libodb-sqlite-2.2.0.a2.zip f27da7710d9346a29aae669adc948748c1a4470b odb-2.2.0.a2-i686-linux-gnu.tar.bz2 d88a2b38fc622639f7873fd685cdb419f90d6fe5 odb-2.2.0.a2-i686-windows.zip b14052d45c91d9e387ac8cda71eaf2c172cce543 odb-2.2.0.a2.tar.bz2 e72a4f56519cb8b44e4634604a72400f6f9acaa0 odb-2.2.0.a2.tar.gz 55f6234a4207682d789e6f916ce3a156c5523d95 odb-2.2.0.a2-x86_64-linux-gnu.tar.bz2 ad309b1cba70ef1eed9b23524f949d422182d4ca odb-2.2.0.a2.zip 81df8e80de7841571473529e919de7ad77156be5 odb-examples-2.2.0.a2.tar.bz2 3b4fd11f52ce28747187cfb77cd9a40e40d28554 odb-examples-2.2.0.a2.tar.gz aafdafda0b324bb814be16f74d44a94b1c85c486 odb-examples-2.2.0.a2.zip 23146cac42ce5014ecc0bf0da66caf0e7fecc6dc odb-tests-2.2.0.a2.tar.bz2 9655496615cb135b6154876a87d80b2b147e9680 odb-tests-2.2.0.a2.tar.gz b8cb3c23754e75fc414f202cce7b9160409d766a odb-tests-2.2.0.a2.zip From pstath at axxcelera.com Thu Dec 13 08:48:12 2012 From: pstath at axxcelera.com (Stath Paul) Date: Thu Dec 13 08:38:15 2012 Subject: [odb-users] Use of shared database pointer in lazy_ptr In-Reply-To: <201212121700.qBCH0EGw012742@codesynthesis.com> References: <201212121700.qBCH0EGw012742@codesynthesis.com> Message-ID: <3233D27CC5658E4598557F8521F6B07E215F81E0D9@RIC-MS01.abw.int> Boris -- I was wondering if there is any way I can utilize a shared pointer to odb::database when I need to construct a lazy pointer. I store my odb::database in a shared pointer. When I construct a lazy pointer, I don't like to borrow the reference to the database from the shared pointer. Seems sloppy, since it may be possible to deconstruct the shared pointer to be database, but still have a dangling pointer to the database in the lazy pointer. -- Paul Stath From boris at codesynthesis.com Fri Dec 14 06:57:52 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Dec 14 06:12:40 2012 Subject: [odb-users] Use of shared database pointer in lazy_ptr In-Reply-To: <3233D27CC5658E4598557F8521F6B07E215F81E0D9@RIC-MS01.abw.int> References: <201212121700.qBCH0EGw012742@codesynthesis.com> <3233D27CC5658E4598557F8521F6B07E215F81E0D9@RIC-MS01.abw.int> Message-ID: Hi Paul, Stath Paul writes: > I was wondering if there is any way I can utilize a shared pointer to > odb::database when I need to construct a lazy pointer. No, there is no way. Short of rolling out your own lazy_ptr implementation (in fact, you can probably "wrap" one provided by ODB). Which is perfectly doable. So if you want to go that route, I can give you more pointers. > I store my odb::database in a shared pointer. When I construct a lazy > pointer, I don't like to borrow the reference to the database from the > shared pointer. Seems sloppy, since it may be possible to deconstruct > the shared pointer to be database, but still have a dangling > pointer to the database in the lazy pointer. We have to draw a line somewhere. ODB cannot be infinitely flexible and customizable (which shared_ptr?, can I also use weak_ptr? etc, etc). So with odb::database we say that it should outlive any other ODB instance that may reference it (lazy_ptr, session, prepared query, etc). For most application, I believe, this is a fairly natural assumption. Boris From prokher at gmail.com Sat Dec 15 12:11:35 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Sat Dec 15 12:01:19 2012 Subject: [odb-users] SQlite ATTACH DATABASE + one minor issue Message-ID: <50CCAF47.107@gmail.com> Hi Boris, first I would like to report an issue. The first time I tries to use "view" feature with my sqlite db I've got the compilation error: view-result.hxx:27: error: expected class-name before `{' token looks like it cannot find result_impl_base . Including #include into sqlite/view-result.hxx fixed the problem. The next thing I would like to ask is why executing (through odb::connection) SQL instruction ATTACH DATABASE '/path/dbfile' AS dst throws Exception: std::exception : 1: near "dst": syntax error The same line works pretty well within sqlite3 command line interface. Actually, the target I would like to achieve is the following. My software works with in-memory sqlite database until user asks to save it to disk. I've googled a little bit and have not found the better way than just to enumerate all the tables using ODB view feature #pragma db view query("SELECT name FROM sqlite_master WHERE type='table';") struct DatabaseTable { #pragma db type("TEXT") QString name; }; odb::result res = _db->query(); then ATTACH destination database and copy all the tables: odb::connection_ptr c(_db->connection()); c->execute("ATTACH DATABASE '/path/dbfile' AS dst"); for (...) { c->execute("INSERT dst.table_i SELECT * FROM table_i"); } c->execute("DETACH DATABASE dst"); but exception occurs :( Exception: std::exception : 1: near "dst": syntax error Probably there is a better way to copy all the data from base to base, I would appreciate any advice here. From prokher at gmail.com Sat Dec 15 13:38:28 2012 From: prokher at gmail.com (Alexander A. Prokhorov) Date: Sat Dec 15 13:28:10 2012 Subject: [odb-users] Re: SQlite ATTACH DATABASE + one minor issue In-Reply-To: <50CCAF47.107@gmail.com> References: <50CCAF47.107@gmail.com> Message-ID: <50CCC3A4.6010905@gmail.com> What concerns the problem with an exception, that is my fault - I've to upgraded sqlite version up to 2.7.15 and everything works smoothly. On 15.12.2012 21:11, Alexander A. Prokhorov wrote: Hi Boris, first I would like to report an issue. The first time I tries to use "view" feature with my sqlite db I've got the compilation error: view-result.hxx:27: error: expected class-name before `{' token looks like it cannot find result_impl_base . Including #include into sqlite/view-result.hxx fixed the problem. The next thing I would like to ask is why executing (through odb::connection) SQL instruction ATTACH DATABASE '/path/dbfile' AS dst throws Exception: std::exception : 1: near "dst": syntax error The same line works pretty well within sqlite3 command line interface. Actually, the target I would like to achieve is the following. My software works with in-memory sqlite database until user asks to save it to disk. I've googled a little bit and have not found the better way than just to enumerate all the tables using ODB view feature #pragma db view query("SELECT name FROM sqlite_master WHERE type='table';") struct DatabaseTable { #pragma db type("TEXT") QString name; }; odb::result res = _db->query(); then ATTACH destination database and copy all the tables: odb::connection_ptr c(_db->connection()); c->execute("ATTACH DATABASE '/path/dbfile' AS dst"); for (...) { c->execute("INSERT dst.table_i SELECT * FROM table_i"); } c->execute("DETACH DATABASE dst"); but exception occurs :( Exception: std::exception : 1: near "dst": syntax error Probably there is a better way to copy all the data from base to base, I would appreciate any advice here. From boris at codesynthesis.com Mon Dec 17 09:40:14 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 17 08:54:03 2012 Subject: [odb-users] SQlite ATTACH DATABASE + one minor issue In-Reply-To: <50CCAF47.107@gmail.com> References: <50CCAF47.107@gmail.com> Message-ID: Hi Alexander, Alexander A. Prokhorov writes: > The first time I tries to use "view" feature with my sqlite db I've > got the compilation error: > > view-result.hxx:27: error: expected class-name before `{' token > > looks like it cannot find result_impl_base . Including > > #include > > into sqlite/view-result.hxx fixed the problem. Yes, that's a bug that has been fixed for 2.2.0. If you would like to get a version with the fix, you can use the 2.2.0.a2 pre-release that we published recently. I've also applied the fix to the 2.1 branch in case we will decide to release 2.1.2 bug-fix (unlikely). > The next thing I would like to ask is why executing (through > odb::connection) SQL instruction > > ATTACH DATABASE '/path/dbfile' AS dst > > throws > > Exception: std::exception : 1: near "dst": syntax error I suspected this was due to an old SQLite version and your follow up confirmed it. > Probably there is a better way to copy all the data from base to base, > I would appreciate any advice here. It looks like the SQLite Backup API was made for that: http://www.sqlite.org/backup.html Boris From boris at codesynthesis.com Tue Dec 18 02:51:35 2012 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 18 02:05:12 2012 Subject: [odb-users] Using ODB on Mobile/Embedded Systems Message-ID: Hi, We just published a detailed guide on using ODB on mobile/embedded systems. It uses Raspberry Pi as a sample target (though other targets can be handled with similar steps) and covers topics such as cross-compilation, building shared/static libraries, footprint, and minimizing the generated code size. http://wiki.codesynthesis.com/Using_ODB_on_Mobile_and_Embedded_Systems Enjoy, Boris