Skip to content

Commit

Permalink
Up to 1.3.2
Browse files Browse the repository at this point in the history
+ ODBC import
+ Database comparison
+ Database search
+ Database statistics
* Multiline comment highlighting
* Fix export to SQL
* Fix SQL import
* Fix minor bugs
  • Loading branch information
little-brother committed Nov 17, 2020
1 parent 34f80c0 commit 55e86db
Show file tree
Hide file tree
Showing 21 changed files with 658,012 additions and 262 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sqlite-gui is a lightweight GUI for [SQLite](https://www.sqlite.org/index.html) powered by C++, WinAPI and [Code::Blocks](http://www.codeblocks.org/).
Sqlite-gui is a lightweight GUI for [SQLite](https://www.sqlite.org/index.html) powered by C++, WinAPI and [Code::Blocks 17](http://www.codeblocks.org/).
Recent binaries are available at [Releases page](https://github.com/little-brother/sqlite-gui/releases).


Expand All @@ -7,10 +7,13 @@ Recent binaries are available at [Releases page](https://github.com/little-broth

### Features
* Syntax highlighting and code completion
* Store an execution history and user gists
* Store an execution history and user scripts
* Export/Import data
* Database diagram
* Database comparison
* Search text in the whole database
* [Workflow manager](https://github.com/little-brother/sqlite-wf) (ETL)
* Quick data references ([video](https://youtu.be/XL1_lFhzLKo))
* Data generator
* Most usefull extensions are included
* Demo database "Bookstore" for beginners
Expand Down
12,320 changes: 12,320 additions & 0 deletions etc/chinook.sql

Large diffs are not rendered by default.

Binary file added etc/chinook.sqlite
Binary file not shown.
639,213 changes: 639,213 additions & 0 deletions etc/northwind.sql

Large diffs are not rendered by default.

Binary file added etc/northwind.sqlite
Binary file not shown.
5 changes: 3 additions & 2 deletions etc/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
dlltool -d sqlite3.def -l libsqlite3.a -D sqlite3.dll
```
* Extension e.g. iif
* Extension e.g. `json1`
```
gcc -I ../include -g -shared json1.c -o json1.dll -s
```
```
`series.c` and `regexp.c` should be compiled with additional flag `-Os` to minimize [VirusTotal alerts](https://github.com/little-brother/sqlite-gui/issues/3)
5,380 changes: 5,380 additions & 0 deletions etc/world.sql

Large diffs are not rendered by default.

Binary file added etc/world.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion sqlite-gui.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Os" />
<Add option="-O" />
<Add option="-std=c++11" />
<Add option="-U__STRICT_ANSI__" />
<Add option="-DUNICODE" />
Expand Down
20 changes: 10 additions & 10 deletions sqlite-gui.depend
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
1562796420 d:\codes\sqlite-gui\sqlite3.h
<stdarg.h>

1603123783 source:d:\codes\sqlite-gui\src\resource.rc
1605609273 source:d:\codes\sqlite-gui\src\resource.rc
<windows.h>
<commctrl.h>
<richedit.h>
"resource.h"

1603004903 d:\codes\sqlite-gui\src\resource.h
1605593216 d:\codes\sqlite-gui\src\resource.h

1603102857 source:d:\codes\sqlite-gui\src\prefs.cpp
1605288374 source:d:\codes\sqlite-gui\src\prefs.cpp
<ctime>
"prefs.h"
"sqlite3.h"
Expand All @@ -43,7 +43,7 @@
1583506689 d:\codes\sqlite-gui\src\sqlite3.h
<stdarg.h>

1603123783 source:d:\codes\sqlite-gui\src\main.cpp
1605610410 source:d:\codes\sqlite-gui\src\main.cpp
"global.h"
"missing.h"
"resource.h"
Expand All @@ -57,19 +57,19 @@

1583970008 d:\codes\sqlite-gui\src\main.h

1603051717 d:\codes\sqlite-gui\src\utils.h
1605587592 d:\codes\sqlite-gui\src\utils.h
<tchar.h>
<windows.h>
"sqlite3.h"

1603104315 source:d:\codes\sqlite-gui\src\utils.cpp
1605587816 source:d:\codes\sqlite-gui\src\utils.cpp
<windows.h>
<stdio.h>
<stdlib.h>
<ctype.h>
"utils.h"

1602016465 source:d:\codes\sqlite-gui\src\tools.cpp
1605610410 source:d:\codes\sqlite-gui\src\tools.cpp
"global.h"
"missing.h"
"resource.h"
Expand All @@ -78,7 +78,7 @@
"dialogs.h"
"prefs.h"

1603107275 d:\codes\sqlite-gui\src\global.h
1605608442 d:\codes\sqlite-gui\src\global.h
<windows.h>
<windowsx.h>
<commctrl.h>
Expand All @@ -91,13 +91,13 @@
<locale.h>
"sqlite3.h"

1600365343 d:\codes\sqlite-gui\src\tools.h
1605592862 d:\codes\sqlite-gui\src\tools.h
<windows.h>

1599763781 d:\codes\sqlite-gui\src\dialogs.h
<windows.h>

1603107275 source:d:\codes\sqlite-gui\src\dialogs.cpp
1605550163 source:d:\codes\sqlite-gui\src\dialogs.cpp
"resource.h"
"global.h"
"prefs.h"
Expand Down
56 changes: 28 additions & 28 deletions sqlite-gui.layout
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,74 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src\tools.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\utils.cpp" open="1" top="1" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="13692" topLine="329" />
<Cursor1 position="3130" topLine="161" />
</Cursor>
</File>
<File name="src\resource.rc" open="1" top="1" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\utils.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="127" topLine="0" />
<Cursor1 position="153" topLine="0" />
</Cursor>
</File>
<File name="src\resource.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="ToDo.txt" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8348" topLine="202" />
<Cursor1 position="1189" topLine="0" />
</Cursor>
</File>
<File name="src\prefs.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\dialogs.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="182" topLine="0" />
<Cursor1 position="25302" topLine="709" />
</Cursor>
</File>
<File name="src\prefs.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\dialogs.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4300" topLine="101" />
<Cursor1 position="263" topLine="0" />
</Cursor>
</File>
<File name="src\missing.h" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\global.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="261" topLine="0" />
<Cursor1 position="2909" topLine="48" />
</Cursor>
</File>
<File name="src\main.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<File name="src\main.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="9067" topLine="123" />
<Cursor1 position="30566" topLine="745" />
</Cursor>
</File>
<File name="src\tools.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\missing.h" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="606" topLine="0" />
<Cursor1 position="261" topLine="0" />
</Cursor>
</File>
<File name="src\global.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\prefs.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2408" topLine="48" />
<Cursor1 position="844" topLine="229" />
</Cursor>
</File>
<File name="src\utils.cpp" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\prefs.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2417" topLine="86" />
<Cursor1 position="182" topLine="0" />
</Cursor>
</File>
<File name="src\dialogs.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\resource.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="263" topLine="0" />
<Cursor1 position="4034" topLine="93" />
</Cursor>
</File>
<File name="src\utils.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\resource.rc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="377" topLine="0" />
<Cursor1 position="16274" topLine="622" />
</Cursor>
</File>
<File name="src\dialogs.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\tools.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="28179" topLine="753" />
<Cursor1 position="64697" topLine="1690" />
</Cursor>
</File>
<File name="ToDo.txt" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src\tools.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="580" topLine="0" />
<Cursor1 position="850" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
47 changes: 33 additions & 14 deletions src/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,28 @@ namespace dialogs {

if (isEdit) {
ShowWindow(GetDlgItem(hWnd, IDC_DLG_EXAMPLE), SW_HIDE);
TCHAR* sql16 = getDDL(name16, type);
TCHAR* sql16 = getDDL(name16, type, true);
if (sql16) {
TCHAR buf[_tcslen(sql16) + 128];
_stprintf(buf, TEXT("drop %s if exists \"%s\";\n\n%s;"), TYPES16[type], name16, sql16);
SetWindowText(hDlgEditorWnd, buf);
SetWindowText(hDlgEditorWnd, sql16);
delete [] sql16;
} else {
SetWindowText(hDlgEditorWnd, TEXT("Error to get SQL"));
SetWindowText(hDlgEditorWnd, TEXT("Error to get DDL"));
}
delete [] sql16;
}
}
break;

case WM_CONTEXTMENU: {
POINT p = {LOWORD(lParam), HIWORD(lParam)};
bool isContextKey = p.x == 65535 && p.y == 65535;
if ((HWND)wParam == GetDlgItem(hWnd, IDC_DLG_EDITOR) && !isContextKey)
TrackPopupMenu(hEditorMenu, TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN, p.x, p.y, 0, hWnd, NULL);
}
break;

case WM_COMMAND: {
HWND hEditorWnd = GetDlgItem(hWnd, IDC_DLG_EDITOR);

if (LOWORD(wParam) == IDC_DLG_EDITOR && HIWORD(wParam) == EN_CHANGE && prefs::get("use-highlight") && !isRequireHighligth) {
PostMessage(hWnd, WMU_HIGHLIGHT, 0, 0);
isRequireHighligth = true;
Expand All @@ -78,18 +86,29 @@ namespace dialogs {
SetWindowText(GetDlgItem(hWnd, IDC_DLG_EDITOR), buf);
}

if (wParam == IDM_EDITOR_CUT)
SendMessage(hEditorWnd, WM_CUT, 0, 0);

if (wParam == IDM_EDITOR_COPY)
SendMessage(hEditorWnd, WM_COPY, 0, 0);

if (wParam == IDM_EDITOR_PASTE)
SendMessage(hEditorWnd, WM_PASTE, 0, 0);

if (wParam == IDM_EDITOR_DELETE)
SendMessage (hEditorWnd, EM_REPLACESEL, TRUE, 0);

if (wParam == IDC_DLG_OK) {
HWND hDlgEditorWnd = GetDlgItem(hWnd, IDC_DLG_EDITOR);
int size = GetWindowTextLength(hDlgEditorWnd) + 1;
int size = GetWindowTextLength(hEditorWnd) + 1;
TCHAR* text = new TCHAR[size]{0};
GetWindowText(hDlgEditorWnd, text, size);
GetWindowText(hEditorWnd, text, size);
bool isOk = executeCommandQuery(text);
delete [] text;

if (isOk) {
EndDialog(hWnd, DLG_OK);
} else {
SetFocus(hDlgEditorWnd);
SetFocus(hEditorWnd);
}
}

Expand Down Expand Up @@ -685,7 +704,7 @@ namespace dialogs {
types[i] = stricmp(sqlite3_column_decltype(stmt, i), "blob") == 0;
SetProp(hWnd, TEXT("BLOBS"), (HANDLE)types);
}
int rowCount = setListViewData(hListWnd, stmt);
int rowCount = ListView_SetData(hListWnd, stmt, true);
ListView_SetColumnWidth(hListWnd, colCount, 0); // last column is rowid

TCHAR buf[256]{0};
Expand All @@ -709,7 +728,7 @@ namespace dialogs {

if (pHdr->code == LVN_COLUMNCLICK) {
NMLISTVIEW* pLV = (NMLISTVIEW*)lParam;
return sortListView(pHdr->hwndFrom, pLV->iSubItem);
return ListView_Sort(pHdr->hwndFrom, pLV->iSubItem);
}

if (pHdr->code == (DWORD)NM_RCLICK && pHdr->hwndFrom == hListWnd) {
Expand All @@ -730,7 +749,7 @@ namespace dialogs {

if (pHdr->code == (DWORD)NM_CLICK && GetAsyncKeyState(VK_MENU)) {
NMITEMACTIVATE* ia = (LPNMITEMACTIVATE) lParam;
return showRefData(hListWnd, ia->iItem, ia->iSubItem);
return ListView_ShowRef(hListWnd, ia->iItem, ia->iSubItem);
}

if (pHdr->code == (DWORD)NM_DBLCLK && pHdr->hwndFrom == hListWnd && !isTable) {
Expand All @@ -754,7 +773,7 @@ namespace dialogs {
bool isNum = kd->wVKey >= 0x31 && kd->wVKey <= 0x39;
bool isNumPad = kd->wVKey >= 0x61 && kd->wVKey <= 0x69;
if ((isNum || isNumPad) && GetKeyState(VK_CONTROL)) // Ctrl + 1-9
return sortListView(pHdr->hwndFrom, kd->wVKey - (isNum ? 0x31 : 0x61) + 1 );
return ListView_Sort(pHdr->hwndFrom, kd->wVKey - (isNum ? 0x31 : 0x61) + 1 );
}

if (isTable && pHdr->code == (DWORD)NM_DBLCLK && pHdr->hwndFrom == hListWnd) {
Expand Down
14 changes: 7 additions & 7 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ extern HWND hMainWnd, hTreeWnd, hEditorWnd, hTabWnd, hSortingResultWnd, hToolti

extern HTREEITEM treeItems[5]; // 0 - current
extern HMENU treeMenus[6]; // 0 - add/refresh menu
extern TCHAR treeEditName[255];
extern TCHAR editTableData16[255]; // filled on DataEdit Dialog
extern TCHAR searchString[255];

Expand All @@ -68,7 +67,7 @@ struct ListViewCell {
};
extern ListViewCell currCell;

extern HMENU hEditDataMenu, hResultMenu, hBlobMenu;
extern HMENU hEditDataMenu, hResultMenu, hBlobMenu, hEditorMenu;

void setEditorFont(HWND hWnd);
void setTreeFont(HWND hWnd);
Expand All @@ -79,13 +78,14 @@ bool processAutoComplete(HWND hParent, int key, bool isKeyDown);
TCHAR* getWordFromCursor(HWND hWnd, bool isTable, int pos = -1);

bool executeCommandQuery(const TCHAR* query);
int setListViewData(HWND hListWnd, sqlite3_stmt *stmt);
int showRefData(HWND hListWnd, int rowNo, int colNo);
bool sortListView(HWND hListWnd, int colNo);
int ListView_SetData(HWND hListWnd, sqlite3_stmt *stmt, bool isRef = false);
int ListView_ShowRef(HWND hListWnd, int rowNo, int colNo);
int ListView_Sort(HWND hListWnd, int colNo);
int ListView_Reset(HWND hListWnd);
LRESULT onListViewMenu(int cmd, bool ignoreLastColumn = false);
TCHAR* getDbValue(const TCHAR* query16);
TCHAR* getDDL(TCHAR* name16, int type);
TCHAR* getDDL(TCHAR* name16, int type, bool withDrop = false);
bool isQueryValid(const char* query);
bool showDbError(HWND hWnd, char* err8 = NULL);
bool showDbError(HWND hWnd);

#endif
Loading

0 comments on commit 55e86db

Please sign in to comment.