SQLite3 Database

Yes, datastores on Roblox use Amazon DynamoDB under the hood. (Fast NoSQL Key-Value Database – Amazon DynamoDB – Amazon Web Services)

1 Like

Looks like I can only store a value and not a table, is there anyway to store a table?
This is the test code I’ve ran.

local sqlModule = require(script.Parent.SqlModule)

game.Players.PlayerAdded:Connect(function(plr)
	local ls = Instance.new("Folder")
	ls.Name = "leaderstats"
	
	local CoinsVal = 0
	local DeathVal = 0
	local canContinue = false
	
	sqlModule:GetAsync("table2", plr.UserId, function(Success, Value, ServerResponse)
		if (Success) then
			-- Value is 'Table 1 key's value or nil, if it doesn't exist.
			
			canContinue = true
			
			if Value.Value ~= nil then
				print("yues")
				for i, v in pairs(Value.Value.value) do
					print(i)
					print(v)
				end
				--CoinsVal = Value.Value.value
			end
			
			print("Success")
		else
			plr:Kick("not success")
			print("Not Success")
			-- Value is the error message, however ServerResponse will contain more detailed information.
		end
	end)
	
	repeat
		wait(.25)
	until canContinue == true
	
	local C = Instance.new("IntValue", ls)
	C.Name = "Coins"
	print(CoinsVal)
	C.Value = CoinsVal
	print(C.Value)
	C.Parent = ls
	
	local D = Instance.new("IntValue", ls)
	D.Name = "Deaths"
	print(DeathVal)
	D.Value = DeathVal
	print(D.Value)
	D.Parent = ls
	
	ls.Parent = plr
	
	wait(1)
	
	spawn(function()
		while wait(5) do
			
			local data = {}
			data["Coins"] = C.Value
			data["Deaths"] = D.Value
			
			sqlModule:PostAsync("table2", plr.UserId, data, function(Success, Value, ServerResponse)
				if (Success) then
					print("Success saved")
					print(Value)
				else
					print(ServerResponse)
					-- Value is Error Message, and third argument is Server Response. (Server Response gives more detailed information about an error)
				end
			end)
		end
	end)
	
	while wait(1) do
		D.Value = D.Value + 2
		C.Value = C.Value + 1
	end
	
end)

Hey there! I’m not sure I can recommend using this in a production game, it was designed for a niche usecase that rarely (if ever) comes up in game development and isn’t as reliable as datastores.

To answer your question, though: You’ll have to JSON Encode/Decode your table. This is pretty much what datastores do as well.

1 Like

What do I include in the URL? I am super confused.


SQLModule = self.Modules.SQLModule
    
    SQLModule:PostAsync("table2", "Pets", "Doggy", function(Success, Value, ServerResponse)
        if (Success) then
            warn("Worked")
        else
            warn("Failed :/")
            print(ServerResponse)
        end
    end)

Keeps failing.

Remove the link from your post, make the glitch project private and reset your API key, please.

As for the URL, you’ll want to preview your app and copy the URL and paste it into the module’s config.image

1 Like

How many keys can this thing hold?

Is there a way to get all data?

You can use * as the key to get all rows. Wouldn’t recommend doing this on any large tables.

1 Like

SQLModule:PostAsync("table2", "Pets", "Doggy", function(Success, Value, ServerResponse)
        if (Success) then
            warn("Worked")
        else
            warn("Failed :/")
            print(ServerResponse)
        end
    end)
    SQLModule:GetAsync("table2", "*", function(Success, Value, ServerResponse)
        if Success then
            print(Value)
        else
            warn("Failed")
        end
    end)


--out put

 {
                    ["Success"] = true,
                    ["ValueExists"] = true
                 }  -