![]() |
|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
Database Recommendations?
I need to make use of a database in one of my plugins and I've never used a database before in Java. I see there are various plugins already available that have to do with database manipulation but I have no idea what they do or how to use them (SQLite JDBC, Sage H2).
My needs are simple. I'm currently storing data as serialized objects in a flat file that I read into memory and search as needed. To speed things up I keep the file loaded in memory but this is causing the plugin to use way too much Java Heap. The database can grow to be several hundred MB. What database systems are available that: - Are either already being used by other plugins (ideal) or can easily be added to the Sage repository? - Have a reasonable learning curve.
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#2
|
|||
|
|||
JavaDB (formally known as Apache Derby) used to be popular. But it really seems H2 is more popular these days. There are a couple of plugins already out there that seem to be using H2. I have played with both, albeit in a limited fashion and I prefer H2. I thought someone else was using H2 in sage, but I don't see it in the libraries list -- maybe ortus was using it..
SQLLite is out there as a dependency already - but I have never used that one. One benefit of H2 (IMO) over JavaDB is that you can have in memory databases - great for unit testing, etc. However, from a difficulty aspect - the should all pretty much be the same. A few lines of initialization code and then just standard SQL. |
#3
|
|||
|
|||
Ya, Ortus uses a H2 database.....but thats as much help as I can give as I didn't set it up
![]() Cheers Ben Edit Actually I think Phoenix uses H2 as well but I can't be sure.
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders Last edited by jaminben; 10-16-2010 at 12:02 PM. |
#4
|
||||
|
||||
Sounds like H2 is the leading candidate. Time to do some reading, thanks.
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#5
|
|||
|
|||
Is it really necessary to store it seperate now with the new userrecord API additions to metadata you could store them there and would be a better way. I have been giving much that to switching smm over to using it. I am assuming you can store you complete custom objects in there but haven't had time to test it yet. I would stay away from a external db if at all possible especially if you don't have any database knowledge.
|
#6
|
||||
|
||||
Quote:
As for not having any DB knowledge, that makes it all the more fun and challenging. A year ago I didn't have any Java knowledge and a year before that I didn't have any Studio knowledge.
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#7
|
|||
|
|||
Quote:
![]() And I know about learning was just trying to steer you away as a database adds allot of maintenance and issues. That said I understand the need an want for an external database so if you power on good luck. |
#8
|
||||
|
||||
You are not putting the whole podcast in there (you might be able as a blob, but...), just links and such, so it shouldn't be that bad...
__________________
SageTCPServer (2.3.5): Open source TCP interface to the SageTV API MLSageTV (3.1.8)/Sage Media Server (1.13): SageTV plugin for MainLobby/CQC TaSageTV (2.58)/TaSTVRemote (1.14): Monitor/control SageTV with an Android device TbSageTV (1.02)/STVRemote (1.11): Monitor/control SageTV with a PlayBook 2 TiSageTV (1.64)/TiSTVRemote (1.09): Monitor/control SageTV with an iPhone/iPod/iPad |
#9
|
||||
|
||||
Quote:
A lot of the data needs to stay around for a long time. For example, when a user downloads an Episode, watches it, and then deletes it. I need to keep track of which Episodes were downloaded and deleted and which were not. I'm open to suggestions on how to use the existing Sage API, but it seems to me that a real database is the best way to go.
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#10
|
||||
|
||||
Aside from that, there may be other advantages to treating the podcasts as mediafiles (the dummy files Plucky mentioned).
__________________
Buy Fuzzy a beer! (Fuzzy likes beer) unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers. Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA. Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S Other Clients: Mi Box in Master Bedroom, HD-200 in kids room |
#11
|
||||
|
||||
After they are recorded they ARE MediaFiles, that's the easy part. It's before they are recorded and after they are deleted that I need to worry about.
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#12
|
|||
|
|||
That's easy use the series API to keep the history an future about each podcast as a series. That would actually work pretty well since jeff opened up that series for us. That would actually work pretty well treat each podcast series as a series.
|
#13
|
||||
|
||||
That's interesting, I'll have to take a closer look at that API.
__________________
Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders. |
#14
|
||||
|
||||
Just to clarify... Phoenix does not use an external database. I did look at H2 at one point, and if I were to use a database, then I'd use H2.
But, to be honest, I haven't found a reason to actually use database to store anything. The new UserRecordAPI was actually something that I had requested as a means to store user defined records in the wiz.bin. Now that it has been added, I don't see any reason to use a database at all. You can store any fields you want in the UserRecordAPI, and as long as you have a primary key (ie, a unique identifier) for each record, then retrieving the data is fairly fast. Also the data can be retreived from the server or the client transparently, like any other sage api. UserRecordAPI has the idea of "stores". "stores" are basically like tables. So you add a new record to a store using a key, and then you have a dynamic record on which you can operate. For example, you might have a feed store, named, "tmiranda.feed", where the primary key is the feed url. You can then store data against that feed url, and retrieve using the feed url. Lkewise you can create a store, "tmiranda.media", where the primary key is the media download url. You can then track watched statuses, fetch date, etc, against the url. you can use the UserRecordAPI in conjuntion with other APIs, such as the SeriesInfoInfo. ie, if you are storing "series" type information, then using the SeriesInfoAPI make sense. If you do decide to use the UserRecordAPI, then I strongly suggest that you prefix all your "stores" with your own identifier. Just so you know, "phoenix.", "sagex." and "bmt." is reserved (the honour system) ![]()
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
#15
|
|||
|
|||
Quote:
![]() Does the user API allow storing custom objects it doesn't appear to but I haven't honestly looked at it hard yet. |
#16
|
||||
|
||||
No, there are no typed objects, just Strings, in the UserRecordAPI. This is consistent with the other apis that have been added to mediafile, series, favorites, etc.
So, if you need to retain a value as an int, boolean, etc, then you'll have to manually convert the data from a string to the required type.
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
#17
|
|||
|
|||
Quote:
|
#18
|
||||
|
||||
One potential downside to storing a large volume of plugin-specific data in Wiz.bin is that people who uninstall your plugin then have no easy way to get rid of that leftover data. Storing it in an external database in a plugin-specific subdirectory makes it easier to find and remove later.
If you do decide to go the Wiz.bin route, you should probably provide a cleanup command that people can use to purge your plugin's data before uninstalling it.
__________________
-- Greg |
#19
|
|||
|
|||
Until recently, I've always used SQLite. It works, but when we looked at adding STVi support for SRE it became apparent that SQLite doesn't fit well when you need to access the DB on the server from a PC client. It was either roll my own client/server comm to access the SQLite DB (lol!!) or move to a client/server DB. Once I started looking at H2 closely it was a no brainer.
I obviously won't remove the SQLite JDBC driver from the plugin repository, but any future projects will definitely be H2 and I'll eventually move my current projects that are still using SQLite (SageAlert) over to H2 at some point in the future. The web console for H2 was an added bonus on top of the client/server architecture. Also, referential constraints that are actually enforced is a really nice thing to have as well. Not that I've tried it yet, but Java classes can be used as UDFs, which kind of caught my attention as well. You can even embed Java code as UDFs directly via SQL. Bottom line, I recommend H2, especially if you need to access the DB on PC clients. And by the time we're done with SJQv4 you'll be an SQL/H2 expert! ![]()
__________________
Twitter: @ddb_db Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive Capture: 2 x Colossus STB Controller: 1 x USB-UIRT Software:Java 1.7.0_71; SageTV 7.1.9 Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter Plugins: Too many to list now... |
#20
|
||||
|
||||
Quote:
![]() Because the UserRecordAPI is made of up stores, as long a devs stick to a consistent naming scheme, it should be fairly easy for someone like yourself to get a list of all of the "stores" and then delete the ones that should not be there... you know, in case the developer doesn't remove their data store automatically, which is bound to happen. If I get time, I'll probably add a data browser to the bmt web ui, so that people can browse the stores, data, remove them, etc. I'd have to agree... H2 is a solid and feature rich database. I think that there is a sagex-h2 plugin in the repository. It's not mine, but I do depend on it in phoenix as well... even though I haven't actually needed to use the database yet. I'd recommend using it, since it has the plugin configuration for setting the port, enabling the servers, etc. We probably don't want to have 4-5 different H2 instances all running inside side.
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wacky Database | noble | SageTV HD Theater - Media Player | 3 | 03-13-2009 08:11 AM |
Database upgrade may take a while... | jzaman | SageTV Software | 9 | 01-08-2007 09:14 PM |
Database help. | stanger89 | SageTV Customizations | 7 | 04-16-2006 03:58 PM |
Database Compatability | wolfpackmars2 | SageTV Software | 2 | 11-07-2005 05:19 PM |