[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Database usage for plugin data
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Database usage for plugin data

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Victorious   (85 posts)  [Biography] 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?
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Victorious   (85 posts)  [Biography] 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?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Victorious   (85 posts)  [Biography] 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?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] 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.


3,654 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]