Pelles C forum

C language => User contributions => Topic started by: TimoVJL on March 02, 2010, 12:50:05 PM

Title: Simple and tiny SQLite3 GUI shell
Post by: TimoVJL on March 02, 2010, 12:50:05 PM
Simple and tiny SQLite3 GUI shell for example.
Use sqlite3.dll from PellesC\bin-folder.
This is a startpoint to someone who want to make it better.

EDIT 20110121: message listview
       20110212: index list
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: jmac on April 13, 2010, 06:49:51 AM
 Hi timovji

I have downloaded your example and am working through it (slowly as yet). Will post an update when I have managed to get some new features working.

Thanks for the great start.

jmac
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: David L Morris on August 07, 2010, 06:57:22 AM
Thanks for this example. It is very generous of you to present such functionality with simple and clear comments. I am sure it will be of great help to those studying C, windows SDK and SQlite database development.  You have also covered printing from the ListView.  A great example.
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: lucindom on February 11, 2011, 02:12:01 AM
Thanks! Excelent Code......

Title: Re: Simple and tiny SQLite3 GUI shell
Post by: TimoVJL on June 30, 2011, 12:21:20 PM
Updated:
- Execute multiple SQL statements separated with ; (semicolons)
- 32/64-bit
- code can compiled with msvc too ?

Let me know if you find any errors in that code.

Small example for multiple SQL statements:
Code: [Select]
#include <stdio.h>
#include <stdlib.h>
#include "sqlite3.h"

#ifdef _WIN64
#pragma comment(lib, "SQLite364.lib")
#else
#pragma comment(lib, "SQLite3.lib")
#endif

int __cdecl main(int argc, char **argv)
{
sqlite3 *db;
int rc;
char *szSQL =
"DROP TABLE IF EXISTS test;"
"CREATE TABLE IF NOT EXISTS test (id INTEGER NOT NULL PRIMARY KEY, text VARCHAR(100));"
"INSERT INTO test VALUES (1, 'text1');"
"SELECT * FROM test;";
char *pSQL1, *pSQL2;


rc = sqlite3_open("test.db3", &db);
if (rc == SQLITE_OK)
{
sqlite3_stmt *stmt;
pSQL1 = szSQL; // at start
do
{
rc = sqlite3_prepare_v2(db, pSQL1, -1, &stmt, (const char**)&pSQL2);
if (rc == SQLITE_OK)
{
int nCols = sqlite3_column_count(stmt);
if (nCols)
{
int nCol;
for (nCol = 0; nCol < nCols; nCol++)
printf("%s\t", sqlite3_column_name(stmt, nCol));
printf("\n");
while ((rc = sqlite3_step(stmt)) == SQLITE_ROW)
for (nCol = 0; nCol < nCols; nCol++)
printf("%s\t", sqlite3_column_text(stmt, nCol));
printf("\n");
}
sqlite3_finalize(stmt);
} else {
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
break;
}
pSQL1 = pSQL2; // next statement
} while (*pSQL2);
sqlite3_close(db);
} else {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return 1;
}
return 0;
}
EDIT 20110630-22:40: TLSQLite3Shell_WS_0_0_3.zip some fixes
EDIT 20110807: TLSQLite3Shell_WS_0_0_3_1.zip ToolBar bitmap
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: TimoVJL on January 16, 2014, 04:59:41 PM
Development version in TLSQLite3Shell_005_UC_WS.zip
Fixes some old bugs and creates new ones ;)

new features:let me know what errors found in this version :(
a6 fix UNICODE error string

EDIT 2016-09-01: a7 DBExec in thread, escape stop thread
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: Grincheux on February 10, 2016, 10:21:09 PM
Quote
SELECT Index,Error,Constante,Hexa,Description FROM WindowsErrorCodes;

NEAR "INDEX":SYNTAX ERROR

Could be useful
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: TimoVJL on February 10, 2016, 11:15:06 PM
I just can't understand that error :(
Can you share that database to look at?
PM link to that?

Or just make a better version from that old code and correct bugs ;)
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: TimoVJL on February 11, 2016, 07:00:00 PM
INDEX is a keyword, look here (https://www.sqlite.org/lang_keywords.html).
Use 'index' like this.
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: Grincheux on February 11, 2016, 07:38:01 PM
Sorry, you are right. In that case the software I use to create the table  would not allow such an item.
That could serve to you, if a user create a field with that name you send an error message.
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: Grincheux on February 12, 2016, 04:23:24 PM
Take a glance at http://sqlitebrowser.org/ (http://sqlitebrowser.org/)
Title: Re: Simple and tiny SQLite3 GUI shell
Post by: Grincheux on February 12, 2016, 04:43:48 PM
And this one : http://www.sqliteexpert.com/download.html (http://www.sqliteexpert.com/download.html)