SQLiteMonkey Programming Forums/User Modules/SQLite
| So I decided to make an incredibly simple wrapper on SQLite.|
At the moment it only supports Windows C++ targets, and I've only tested it with cpptool using MinGW.
Here's what I want to know:
1) Which targets you would like to see it on? Suggest some and I'll give you an estimate on how much work is required, if it's possible or feasible to do.
2) What features would you like to see wrapped? At the moment it lets you open a database, execute statements, and loop through result sets.
| Awesome! |
| Awesome! - I'd love to see this on iOS!|
I'm not sure what you mean by 'features', but would being able to order the results count?
@rIKmAN: I'm not sure what you mean by 'features', but would being able to order the results count?
format_code('SELECT Foo FROM Test ORDER BY Foo')
Note that the design is currently very volatile. I essentially wrapped the official structs and functions and made them a bit cleaner to use. Other targets may have a slightly different implementation, and I'll have to hack them to work the current way.
I may end up designing it from a usability perspective, then implement each target whichever way it needs to. I was considering having a common "sql" interface so that there's the possibility of plugging in other drivers later, but I don't see any reason why you would need to support Oracle or MSSQL... maybe someone can enlighten me on why a game would need something that complicated.
| Yeah that's exactly the syntax I meant Samah, and I know it wasn't really a feature but I wasn't sure what you meant by that.|
What other features were you thinking of?
Oracle / MSSQL would be overkill for games imo, SQLite is perfect - quick, light and simple.
If you need any to help test when you get round to working on it for iOS let me know, I'd be happy to help :)
| This is totally killer. Can't wait to see it hit other platforms if it gets to that point. In another language I wrote the beginnings of a GUI library that made extensive use of in-memory sqlite to hold the data rather than lists and classes. It would be cool to continue that work in monkey. |
| This is cool. Do you ever stop and not code? Your worse than Brucey you are Mr Samah. :)|
If Android is supported then I'm good to go.
Thank you for this.
| Sorry for being inactive with this, I've got a million projects on my plate and a new job coming up soon (Objective-C and Swift). iOS and Android will probably be my next target.|
Question: Would you guys prefer that this just be a SQLite wrapper with 99% mapped functions, or do you think it would be good to make it less DB specific? I can't see the point for having drivers for other databases since this is client-side and not server-side. The catch with the current implementation is that the developer needs to actually know all the raw calls to SQLite.
I might see how hard it is to actually include the source directly into the generated file, like Mark's GLFW configuration.
Continued from: http://www.monkey-x.com/Community/posts.php?topic=10165&post=111879
@Raz: ...does that include GLFW?
@Raz: I'm currently getting...
Looks like you haven't added sqlite to the libraries, so the linker can't find it. Did you do steps 2 and 5 in the configuration?
format_code('2) Copy "libsqlite3.a" to MinGW/lib
5) Add to CONFIG.MONKEY in the build directory: #CC_LIBS="-lsqlite3"')
| Hi Samah, yup I believe I've completed all of those steps.|
With regards to copying the dll, I put this in the same directory as CONFIG.MONKEY, is that correct?
| Right, I've managed to static link sqlite3 directly into MonkeyGame.exe. It just requires some hacking to the GLFW3 target. (static linking means you don't need the DLL any more)|
No need to mess around with your MinGW installation either. :D
You'll want the first zip file, "sqlite-amalgamation-3090000.zip"
1) Create a new directory in MonkeyXPro/targets/glfw3/template called "sqlite3"
2) Copy "sqlite3.c" and "sqlite3.h" into that directory
3) In the gcc_winnt directory, open Makefile in a decent text editor (not notepad)
4) In the CPPFLAGS section, change the last line to (note the ending backslash):
5) Before the line "vpath %.cpp ..", add the following:
format_code('vpath %.c ../sqlite3')
6) In the OBJS0 section, before context.o, add (note the ending backslash):
It would be nice if there was a way to set all this stuff in the Monkey source, but we're limited as to what we can configure without modifying the template.
If you want to cheat:
LDFLAGS=-Wl,--subsystem,windows -L../openal/libs/Win32 -L../openal/libs/Win64
LDLIBS=-lcomdlg32 -lgdi32 -lopengl32 -lOpenAL32 -lws2_32
vpath %.c ../glfw3/src
vpath %.c ../stb
vpath %.c ../sqlite3
vpath %.cpp ..
all : $(OUT)
$(OUT) : $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
$(TMP)%.o : %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
$(TMP)%.o : %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<')
| Woop, just managed to give it a proper try and it works a treat :D |