Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Create an SQLite Database at runtime?...


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Sep 15, 2014 6:34 AM Last Post By: John Marinuzzi
John Marinuzzi

Posts: 12
Registered: 3/2/07
Create an SQLite Database at runtime?...  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2014 9:46 AM
I have been searching for how to do this on the forums but coming up with little success. I am using XE5 and plan to use an SQLite DB for logging data and using the data for reports. I have managed to connect to existing DBs fine, but in this case would like to create the DB at runtime. I will be using TSQLConnections. I tried adding the sqlite.h file directly but then get redefinition conflicts. Has anybody done this or have any suggestions on how to achieve it?
Dale Chant

Posts: 13
Registered: 4/6/08
Re: Create an SQLite Database at runtime?...  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2014 8:38 AM   in response to: John Marinuzzi in response to: John Marinuzzi
John Marinuzzi wrote:
I have been searching for how to do this on the forums but coming up with little success. I am using XE5 and plan to use an SQLite DB for logging data and using the data for reports. I have managed to connect to existing DBs fine, but in this case would like to create the DB at runtime. I will be using TSQLConnections. I tried adding the sqlite.h file directly but then get redefinition conflicts. Has anybody done this or have any suggestions on how to achieve it?

Hi John,

We have SQLite compiled into a large VCL C++ project (both 32 and 64 bit) with no redefinition conflicts. SQLite3.c is simply included in the project. You will I think need the single file version - should be available from the SQLite home site. The header comments are:

/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
** version 3.7.15.2. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements
** of 5% or more are commonly seen when SQLite is compiled as a single
** translation unit.
**
** This file is all you need to compile SQLite. To use SQLite in other
** programs, you need this file and the "sqlite3.h" header file that defines
** the programming interface to the SQLite library. (If you do not have
** the "sqlite3.h" header file at hand, you will find a copy embedded within
** the text of this file. Search for "Begin file sqlite3.h" to find the start
** of the embedded sqlite3.h header file.) Additional code files may be needed
** if you want a wrapper to interface SQLite with your choice of programming
** language. The code for the "sqlite3" command-line shell is also in a
** separate file. This file contains only code for the core SQLite library.
*/

As it says above, the header material is incorporated into SQLite3.c, so you should not need SQLite3.h.

We only read a 3rd party SQLite DB, so cannot help you on runtime creation.
John Marinuzzi

Posts: 12
Registered: 3/2/07
Re: Create an SQLite Database at runtime?...  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 15, 2014 6:34 AM   in response to: Dale Chant in response to: Dale Chant
Dale Chant wrote:
John Marinuzzi wrote:
I have been searching for how to do this on the forums but coming up with little success. I am using XE5 and plan to use an SQLite DB for logging data and using the data for reports. I have managed to connect to existing DBs fine, but in this case would like to create the DB at runtime. I will be using TSQLConnections. I tried adding the sqlite.h file directly but then get redefinition conflicts. Has anybody done this or have any suggestions on how to achieve it?

Hi John,

We have SQLite compiled into a large VCL C++ project (both 32 and 64 bit) with no redefinition conflicts. SQLite3.c is simply included in the project. You will I think need the single file version - should be available from the SQLite home site. The header comments are:

/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
** version 3.7.15.2. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements
** of 5% or more are commonly seen when SQLite is compiled as a single
** translation unit.
**
** This file is all you need to compile SQLite. To use SQLite in other
** programs, you need this file and the "sqlite3.h" header file that defines
** the programming interface to the SQLite library. (If you do not have
** the "sqlite3.h" header file at hand, you will find a copy embedded within
** the text of this file. Search for "Begin file sqlite3.h" to find the start
** of the embedded sqlite3.h header file.) Additional code files may be needed
** if you want a wrapper to interface SQLite with your choice of programming
** language. The code for the "sqlite3" command-line shell is also in a
** separate file. This file contains only code for the core SQLite library.
*/

As it says above, the header material is incorporated into SQLite3.c, so you should not need SQLite3.h.

We only read a 3rd party SQLite DB, so cannot help you on runtime creation.

Thanks for the reply, Dale. I have used and compiled sqlite.c itself in projects before with no problem. The situation this time is I would like to use some of the dbExpress and FastReport tools. When I include those along with sqlite is when I run into problems. And the only reason I need to include them is to create a DB that does not already exist. Doing this gives me a "Multiple declaration for sqlite_mutex_methods." It seems Embarcadero redefined a bunch of the sqlite functions, but not the one to create a DB (sqlite_open).
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02