Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Plugins ➜ Database usage for plugin data

Database usage for plugin data

Posting of new messages is disabled at present.

Refresh page


Posted by Victorious   (89 posts)  Bio
Date Fri 13 Nov 2015 04:52 PM (UTC)
Message
Hi,

I've used serialize.save_simple so far to save plugin state. After taking an introductory course in database systems though at university, I've been thinking about switching over to using sql lite.

What would be the downsides of switching to this? For example, how fast would the queries be compared to say hand-coding traversal of lua tables to achieve the similar result (which is what I used to do before I learnt SQL)? SQL lite also doesn't fully support alter table, which is something I may need to do for e.g a new version of the plugin adding a new option, how much of a problem is this?
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #1 on Fri 13 Nov 2015 10:30 PM (UTC)

Amended on Fri 13 Nov 2015 10:32 PM (UTC) by Fiendish

Message
You can work around not being able to alter table with a little dance of copy table, drop table, create table, select->insert, drop table. The only real issue I've ever had with sqlite is its lack of either NATURAL OUTER or FULL OUTER join, I forget which one, but it was definitely one of them, and the only real workarounds require knowing the table columns ahead of time which I couldn't because of the configurable nature of the project. I ended up implementing them brutefully in Python, which the rest of the project was written in.

I don't see what this has to do with serialize, though.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 14 Nov 2015 12:13 AM (UTC)
Message
Quote:

I don't see what this has to do with serialize, though.


It's a discussion about how to save state, basically.




I used the SQLite3 stuff for the mapper (in some cases) and found it quite fast enough. For multiple updates, put them inside a transaction. For reading, it is fast.

What you can do (and I think I did in the mapper) is cache things from the database into a Lua table - for reading, not updating.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Victorious   (89 posts)  Bio
Date Reply #3 on Sat 21 Nov 2015 06:48 PM (UTC)
Message
Hm, doesn't that not allow you to perform sql queries if you read the database entries into a table, and so have to code that yourself?
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 21 Nov 2015 09:04 PM (UTC)
Message
Does what not allow you to what?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Victorious   (89 posts)  Bio
Date Reply #5 on Sun 22 Nov 2015 04:10 AM (UTC)
Message
Converting it into a lua table, doing that won't allow you to run sql queries against the table?
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #6 on Sun 22 Nov 2015 04:56 AM (UTC)
Message
No, you can't run SQL queries against a Lua table, but what did you have in mind? Data in a table can usually be looked up by key, or by searching (eg. string.match) of things that you want in the data.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


20,007 views.

Posting of new messages is disabled at present.

Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.