Is honeysql RDBMS agnostic? - clojure

I would like to use honeysql https://github.com/jkk/honeysql with MySQL and with SQlite at the same time.
Can I do so? Will resulting queries work in both RDBMS systems?

From the README :
To quote identifiers, pass the :quoting keyword option to format. Valid options are :ansi (PostgreSQL), :mysql, or:sqlserver:
So I don't think sqlite is supported

Related

RDbms name and version

I m doing a software in c++ that permit to access to some rdbms with qt library.
The software is only for pc.
The software need to know the name of rdbms and version beacuse the program needs to choose some sql query to execute. Is there any way to retrieve thisdata in any rdbms?
Is there any way to retrieve thisdata in any rdbms?
This is specific to each RDBMS - for example, in Oracle, you can do
select *
from v$version;
but in other RDBMS this view does not exist.
Some possible approaches:
You need to define connect parameters somewhere anyways. Even they are often RDBMS-specific, so you could simply add another parameter like SQLFlavor=Oracle or SQLFlavor=MySQL and then use the value of SQLFlavor in your code to determine which SQL statement to use
You can use some heuristics to find out the RDBMS. For example, query the v$version view - if it does not exist, you will get an error and you know that it is not Oracle and you can continue with the next try (like SELECT VERSION() to see if it is MySQL). Otherwise, you can use the result to find out the concrete Oracle version.

How to set the sqlite parameters using C++

I need to set some parameters in sqlite like turning the headers on: (.headers ON), setting the output mode to csv : (.mode csv) and I require this to be done with C++ instead of the sqlite command line tool.
Can I know whether it is possible or not, and if possible, how to achieve this (using example)?
Thanks
The dot commands are conveniences of the sqlite command line tool. They are not available using the API. CSV is quite easy to build yourself, though.

Does ORM ODB for C++ Object Persistence Create/Re-Create DB

I am fairly new to this library, and ORM in general. I know tools like EntityFramework can generate a database from your objects, and can generate code from a database. Can ODB for C++ do anything similar? If not, are there libraries that can do such, for C++? Thanks in advance
Yes, ODB can generate database schema (i.e., DDL statements) for your C++ object model. You can have it either as a separate .sql file or embed it into the C++ code and create the schema programmatically from your application.
See the --generate-schema and --schema-format options in the ODB Compiler Manual.

Store MySQL table to file (sqlite?)

I wrote a C++/QT application that uses a mysql database for its data. It's using the mysql++ library. I now want it to be able to export and import its data to/from files.
I could write an own file format, but I'd like to elude this efford, if possible.
Is there an easy possibility to export a mysql table into a file and to reimport this file with C++?
I heard of sqlite, but as far as I read, migrating from mysql++ to sqlite is not that easy, because it includes a switch of the complete database backend.
You can use "LOAD DATA " and "SELECT ... INTO OUTFILE"
That should have great performance. You may not use the outfiles further as easily as you want.
The best way to export/import data from/to a database is xml files.

What is the easiest way to persist maps/structs in Clojure?

The obvious way is to load up JDBC support from Clojure Contrib and write some function to translate a map/struct to a table. One drawback of this is that it isn't very flexible; changes to your structure will require DDL changes. This implies either writing DDL generation (tough) or hand-coding migrations (boring).
What alternatives exist? Answers must be ACID, ruling out serializing to a file, etc.
FleetDB is a database implemented in Clojure. It has a very natural syntax for working with maps/structs, e.g. to insert:
(client ["insert" "accounts" {"id" 1, "owner" "Eve", "credits" 100}])
Then select
(client ["select" "accounts" {"where" ["=" "id" 1]}])
http://fleetdb.org/
One option for persisting maps in Clojure that still uses a relation database is to store the map data in an opaque blob. If you need the ability to search for records you can store indexes in separate tables. For example you can read how FriendFeed is storing schemaless data on top of MySQL - http://bret.appspot.com/entry/how-friendfeed-uses-mysql
Another option is to use the Entity-Attribute-Value model (EAV) for storing data in a database. You can read more about EAV on Wikipedia (I'd post a link but I'm a new user and can only post one link).
Yet another option is to use BerkeleyDB for Java - it's a native Java solution providing ACID and record level locking. (Same problem with posting a link).
Using CouchDB's Java-client lib and clojure.contrib.json.read/write works reasonably well for me. CouchDB's consistency guarantees may not be strong enough for your purposes, though.
Clj-record is an implementation of active record in clojure that may be of interest to you.
You could try one of the Java-based graph databases, such as Neo4J. It might be easy to code up a hashmap interface to make it reasonably transparent.
MongoDB and it's framework congomongo (lein: [congomongo "0.1.3-SNAPSHOT"]) works for me. It's incredible nice with the schemaless databases, and congomongo is quite easy to get along with. MongoDB adds an _id-field in every document to keep it identified, and there is quite good transparency between clojure-maps and mongo-maps.
https://github.com/somnium/congomongo
EDIT: I would not use MongoDB today. I would suggest you use transit. I would use JSON if the backend (Postgres etc) support it or the msgpack coding if you want to have a more compact binary encoding.