4.6 How to use SQLiteSupport?

Hello, could anyone make a small tutorial how to use SQLiteSupport module with some simple read and write example?

P.S. I’m stuck at “WITH_SQLITE” because it’s grayed out and I’m not sure where I have to define it.

Hi ,
There were a few minor issues with the integration of SQLite support in 4.6 that became apparent after that release was branched. If you are using a Github build of the engine, you can merge in these two changes from the master branch:

https://github.com/EpicGames/UnrealEngine/commit/0aa0b62243a9f90de1b357e10f623b04b85de298
https://github.com/EpicGames/UnrealEngine/commit/170b9329e934b959491112b1f1a9cad8ddc665f1

They remove the need for the WITH_SQLITE defines, amongst other things, including improving the crossplatform support of the library.

With those merged you should be able to simply add SQLiteSupport as a dependency module and then do something like this:

//create and open the database
	FSQLiteDatabase Database();
	Database.Open("Path\\To\\File", nullptr, nullptr);
	//run query where no results are returned
	Database->Execute(*(FString::Printf(TEXT("Update GameSession set SessionTimeEnd= %s where SessionID = %s"), *(FDateTime::Now().ToString()), *(FApp::GetSessionId().ToString()))));
	
	//run query to fetch results from database
	FSQLiteResultSet* NameResults = NULL;
	if (Database.Execute(*(FString::Printf(TEXT("Select * from Players where SessionID = %s;"), *SessionID)),NameResults))
	{
		for (FSQLiteResultSet::TIterator NameIterator(NameResults); NameIterator; ++NameIterator)
		{
			//do something with the results here
		}
	}

Thank you a lot, it did work!

Where did you find info about SQLite support getting added to the engine? It’s not in the patch notes, so I was just curious where I could read about it.

On the forum post with additional details, waaay down towards the bottom there’s a mention of the SQLite support being added as an optional module.

Just wanted to mention this here:

SQLite only supports a single writer at a time (meaning the execution of an individual transaction). SQLite locks the entire database when it needs a lock (either read or write) and only one writer can hold a write lock at a time. Due to its speed this actually isn’t a problem for low to moderate size applications, but if you have a higher volume of writes (hundreds per second) then it could become a bottleneck.

We hope this plugin can help you.

HiSQLite3 (SQLite3 For UE4)