Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ DBI Class - best/developer friendliest style
    text
    copied!<p>In our current project, we need some high level DBI for different databases. It should provide the following features:</p> <ul> <li><strong>in memory cache</strong> - the DBI should be able to cache all reads, and update the cache on writing calls (the application we are coding on is heavy threaded, and needs fast access to the current data all the time). The memory cache will be based on <code>boost::multi_index</code></li> <li><strong>automatic sql building</strong> - We don't want to parse a sql statement to lookup in the memory cache</li> </ul> <p>As we need to provide functions for: defining a table layout, do selects, do inserts, do updates, joins, ..., the interface will get very complex.</p> <p>We need a good way to invoke the interface function.</p> <p>There are many styles around, but we could not find any useful for our usage.</p> <p>Here a few examples:</p> <p><strong>SOCI</strong></p> <pre><code>sql &lt;&lt; "select name, salary from persons where id = " &lt;&lt; id, into(name), into(salary); </code></pre> <p>We don't want some SQL statements, so we would have to define <code>what</code> and <code>from</code> a different way.</p> <p><strong>pqxx</strong></p> <pre><code>Conn.prepare("select_salary", "select name, salary from persons where id = $1") ((string)"integer",prepare::treat_direct); </code></pre> <p>The heavy usage of the overloaded <code>operator()</code> is just ugly, but it could work for us too.</p> <p>Any suggestions how to <em>design</em> the interface?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload