C++ Database API's - DTL - c++

I'm looking for a C++ API that is able to connect to different types of databases all in one; mainly MySQL, oracle and SQL Server and I believe I have found one with "DTL" ( http://dtemplatelib.sourceforge.net/ )
However, I'm struggling to connect my database on localhost. Has anyone used this before and could shed some more light on it other than what their site does with
DBConnection::GetDefaultConnection().Connect("UID=example;PWD=example;DSN=example;");
though I guess what to put in uid and pwd, I'm not sure what it's expecting in 'dsn', are there any REAL examples or have you guys used it before and could help.

This is an ODBC library, so DSN is the ODBC data source name. On Windows, these can be configured under Administrative Tools->Data Sources.

As #Dark Falcon said, the "DSN" refers to an "ODBC data source". What you get is an extra level of indirection like this:
On Windows, you normally create the ODBC data source with the "Data Sources (ODBC)" control panel, which is normally in the "Administrative Tools".
In any case, this separates the configuration/deployment "stuff" from the code. For example, if you want to use your code with a test database during development, then with the "live" database when you deploy it, you can do that without making any changes to your code, and even without changing the connection string. Instead, you change the data source to refer to production server instead of the test server.

Related

How can I make a SQL application work offline?

I'm making a c++/Qt application. It connects to a small online database to find different information. I need to make sure that the application works offline. So I would like to do the following
On start up of application:
- Check if internet connection is available
- if available connect to online database, download database to local (for next time no internet is available)
- if not available connect to the kocally stored version of the database
My problem is I can't find a simple solution how to "download" the database. The user will not update the database, so there is no need for syncing when online again, just the ability to download the newest version of the database, whenever online. It is a MS SQL server that the application uses.
My only idea for a solution is to have an SQLite db in the application, and then write a script that clears the SQLite database and then puts everything from the online server into it, but this requires that I write a script that goes through all of the databse. There must be a better solution. I'm also not sure how this solution should work if the database structure changes. A solution for this could just be to send out a update for the application if the structure changes with a new SQLite db with the new structure.
I tried searching for a solution, but I could not find anything that are simple. Since I don't neew syncing back and forth, I thought there must be a simple solution. Any help pointing me in the right direction is appreciated.

Python Database Connection String with Derby Database

Just to let you know about the problem i am facing, I will give a short introduction about what I have been doing.
I am working on a project, where the WEB interface is constructed in Java.
There is a parser built in python, which parses data and stores it into the database.
We were using a MySQL server, but were later asked to change it into DERBY. The java code now works perfectly connecting with the database.
But the python part of the code has problems with connection. I learnt how the derby database works, but find it hard to find articles about connecting to a derby database.
I have the following details:
uname : root
pwd : root
driver class : org.apache.derby.jdbc.EmbeddedDriver
DRIVER LOCATIONS : C:\Users\esusank\AppData\Roaming\RazorSQL\derby\derby10.10.jar
JDBC URL : jdbc:derby:C:\Derby\databases\MyDbTest;create=true
I am finding it hard to find syntax for writing a connection string for DERBY.
I have installed mxODBC driver.
Can someone help me out on this? If you can post some links or some suitable syntax, it will be very much helpful.
To communicate with Derby, you will need to use a JDBC driver. ODBC drivers can't talk directly to Derby; it is a Java-only database.
I believe there are some ODBC-JDBC bridge providers that provide such connection mechanisms, but I'm not sure if they are still in active use.
Another possibility is to use Jython, which is a Java implementation of Python, which may help: see this related question: Derby Database ODBC Connection

How to use SQLite database from one platform(iOS) to another(Windows)

I don't know its a valid question or not.
I am working on one MFC/C++ application where
I want to use SQLite database from iOS application in my windows application.
My iOS database is encrypted using command sqlite_key.
While I am trying it for my windows application for the same database
It throws an exception for any operation on the database.
While Searching on Google I am not able to get right track for this.
Can anyone tell me is it possible?
And if yes please help me on this.
If your plan is to "export" it, i.e you want to reuse the data inserted by your ios application into your windows one, then you simply need to locate on your iphone the sqlite database file (sqlite store everything in one single location) and copy it on your computer, and tell your windows software the location of this file.
If your is to "share" the database, i.e both should be able to modify it in "realtime", then you will have to roll something on your own, as Sqlite3 does not provide any network support, it's just a library to read and write data in a file, in a SQL way.

C++ Database Connection

I need to connect to a database with c++, I have tried to use mySql++, mySql connector, and a few others however I am unable to get them running, I've tried the tutorials but I can't seem to get them right. VS doesn't see the files that I try to include.
Anyways, Is there a somewhat easy way to connect to a database using c++ without needing to download a ton of files or api's. and if so could you please provide a link to a tutorial, ive tried using ODBC, however I don't think ive been doing it right as it shows a ton of errors in my code.
any help would be appreciated,
Thanks
How about OTL. It is just a header file so far away from tons of files. And all you need is the libraries depending on the DB you want to connect to.
ODBC is a little bare metal - surely there are some more accessable ADO classes (you might need MDAC)?
First, you have to know what kind of database you have to connect to. It does matter, as you won't use the same API to connect to a MySQL database, or to a SQLite one, or Oracle, or Postgres, or SQL Server ...
Then, have a look at the library that allows acces to the database. And make sure that the database is actually present!
C++ Standard doesn't has native database support. You cannot connect to a database using C++ without database/platform specific libraries. Such as this or this one, if you want to connect to MySQL server.

MS Access backend for django

I've been working on a modification of the django-pyodbc package so that it could be used with MS Access.
I need this for a legacy database we are tied to at my organization, and have been doing a rather hacky job specific to my situation, but have also been making useful, generalizable progress in terms of adapting SQL syntax for MS Access.
My question is, is this a project that anyone else in the world is interested in? should I clean up my code and try to fully generalize it, or is everyone else in the world able to solve their MS Access problems by moving to SQL server?
I would move the data to SQL Server if that is an option.
If moving the data is not an option and if my Django app is already connecting to SQL Server, I might just create a linked server on SQL Server and go through SQL Server instead.