SQLite3 Database

EDIT: As posted in a reply,

This is a very simple server I made in node-js which gives a roblox script access to storing, getting and deleting information. I made this to be hosted on glitch, since most people do not have access to their own VPS. All tables are key/value like datastores, however unlike datastores you can easily write specific information, without messing up any other information. Such as a table for users, you can get all users, or a specific user and you can also write to a specific user without messing with all other users.

The source code for both the server and roblox code is in my github repo as well as how to setup everything on Glitch and in roblox.

I’m only going to go over the actual roblox code’s api however it is all documented on the github page.

The roblox script is a module and can be required after being put into a ModuleScript in your game.

Examples for all code can be found here, because discourse’s formatting isn’t the best for code.

sql:GetAsync(string Table, string Key, function Callback)
Read information from a table inside of your database.
Example

sql:PostAsync(string Table, string Key, string Value [, function Callback])
Write information to a specific table inside of your database.
Example

sql:DeleteAsync(string Table, string Key [, function Callback])
Delete information from a specific table inside of your database.
Example

I apologize in advance if I’m not that good at explaining things.

If you have any criticism, issues or complaints about any of my code, please feel free to tell me and I’ll try and solve the issue.

32 Likes

What?

3 Likes

I apologize, I’ll try and explain a bit better.

With a datastore, you have the datastore and within the datastore you can set a key to a specific value. This is the same, however each ‘table’ is like a new datastore. With normal datastores, you cannot receive all data that is written into the datastore. This means if you want to have all your information accessable with one datastore request, you’d have to store one key with all the users. If you wanted to write to a specific user, you’d have to write all the data on the key in your datastore, and if another server for example is also saving information, it could cause one of the servers to lose information, since they both wrote to the same thing with different information.

With this, you can recieve all information inside of the table, but all keys can also be written to directly instead of having to write ALL data at the same time.

For an example, if you have a table for all users and their data, you can read ALL data from a table every 30 seconds, but only write to a specific key whenever you modify a user’s data. This prevents two servers from trying to change the same thing at the same time (which makes one server lose information that they were trying to save)

If this doesn’t make sense I apologize, I’m just not good at explaining things.

3 Likes

I am still quite confused could you draw a diagram which explains what happens when you save data? Also what are the limits (I assume 500 request per 60 secs)? Can it be used for large projects?

2 Likes

I’ll do it after I get back in likean hour, sorry.

1 Like

Alright :+1:

So I’m just curious, why make a SQLite3 Database API but keep the functionality the same to that of Roblox Datastores?

I would have made it functional to that of real SQL. I’m sorry if I don’t quite understand but what would make this a better benefit over using regular Roblox Datastore if it functions mostly the same way? From what I see it looks like what you’re trying to do is make a bit more reliable ways of storing and fetching data but also open just a small amount of API’s to do more things. Similar to what you’re making could be to that of RedisDB which is a memory caching server.

In my mind you seem to have made it more complicated than it should’ve been.

2 Likes

I actually planned to make a full SQL access api, however because it’s not necessarily super secure, I decided to do this first. The main thing for this is it’s external (which means you can back it up) and also if used correcly it can be better as far as cross-server saving data

What’s the reason you think it wouldn’t be secure? Isn’t this a system entirely ran by the developer and it’s at their sole discretion how secure it is? Do you think that developers may program in accidental SQL injection or some other exploit?

Actually, I guess thinking about it they’re both as secure as each other. I was thinking of the token being leaked, and someone running any sql queries, but either way this version has get, set and delete which could be used maliciously just as the other one. I’m wrong, it wouldn’t be any less secure than this version.
This is meant to be simple for anyone to use, rather than people who know sql. I’ll gladly work on a full SQL (as I had planned to)

Alright cool, thanks for clarification! I’ll be on the look out for this and it would be cool to have one that could interface with basically any database a developer chooses in an all in one library.

Your problem with leaking tokens though is something you can’t possibly program to work around. I would just have ways of setting a new token or other. Sometimes being too security focused can lead to lack of features in a library, not that it’s a bad thing, but you shouldn’t limit yourself just because of user error.

1 Like

The only database I’ve had past experience with is SQL (sqlite, mysql, etc) however I may look into other databases, and I do sometimes over focus on security especially ever since one of my projects got leaked a few years ago.

Considering the instability of Datastores ATM, an community managed open sourced database service with implemented REST apis and API key generation would be amazing. This would allow us to run our own databases for the times in which Datastores are experiencing issues and data still needs to be pushed/retrieved from somewhere.

SQL is quite universal in other databases so this shouldn’t be a problem. You can always message me on here if you need some help with NoSQL implemented if you plan to add that in as I may be willing to chip in some advice or knowledge. I’ve personally worked with MongoDB.

I’ve used MongoDB for a node server I had a while ago, wasn’t the most fun thing to work with, but if you’d like we could both help work on setting up an open sourced service (as Reinitialized suggested above) like this, but of course support multiple databases(with sql and nosql), if you would want to help out with that.

1 Like

You should make a video for this. Would be MUCH easier to have a visual to follow by.

Mmmmm SQLite is definitely not scalable like Roblox’s Data Stores are. This looks more like a proof of concept or exercise project moreso than something you’d want to use in a large-scale production work.

I wasn’t thinking SQLite for this very reason (tho there are adaptions of SQLite such as this), but such a community supported project would be something I’d be very interested in.

1 Like

What about something like Amazon Aurora?

For some reason I just have a hard time using data stores in general and think if they where designed more like databases they’d be eaiser to use.

Data stores already use AWS under the hood* - doing so would arguably be a waste of development time. But if you’re wanting to learn real world backend skills, I highly recommend giving it a shot. Databases are among the most common topic taught in CS and IT courses in college.

*This is a best guess for me, because big data store outages are often linked to AWS outages, not because of some public knowledge Roblox has released. I don’t have any insider knowledge on the technologies involved.

1 Like