Archive | MySQL

The open source database, often the default.

Retro-tagging a WordPress blog

I’ve got a WordPress blog with a couple thousand posts, upgraded several times, from a TWiki blog to a Radio Userland blog to WordPress and a couple of upgrades. And I’d like to add the new taggin features available in WordPress 2.3. Here’s what I’ve figured out from poking around: what used to be wp_category is now wp_terms and terms contains both categories and tags. The categories are hierarchical from a self-join using the group column to link back into the term’s term_id primary key. wp_terms in turn links into wp_term_taxonomy: that’s got a column named taxonomy that contains groups like ‘category’ and ‘link_tag’ and a parent column that self links into term_id, which I think is a duplication of what wp_terms is doing. There’s also a count field, meaning that we’re denormalizing the count of categories and tags, meaning if we hack at them, we’ll need to manually update this (see below). Finally, the posts are related to categories and tags using the table wp_term_relationships that’s a many-to-many link from the post’s primary key, object_id, to the term_taxonomy_id primary key of the wp_term_taxonomy table.

So, here’s the recipe to retrofit tags into some posts. I used phpMyAdmin as the web interface into the MySQL table that holds WordPress’ data. You can do the same via the mysql terminal interface or using other remote connectivity like ODBC or your choice of tools.

1. Create or update a tag in the wp_terms table. Note the term_id PK.
2. Insert the term_id and category of ‘post_tag’ into the wp_term_taxonomy table.
3. Create the linking records in wp_term_relationships with the following SQL. In this case, I’m tagging with “Ruby” any post that has “Ruby” in the title or post.

INSERT INTO wp_term_relationships
SELECT wpp.id object_id, `term_taxonomy_id`
FROM wp_posts wpp, `wp_term_taxonomy` wptt
JOIN wp_terms wpt ON wptt.term_id=wpt.term_id
WHERE wpt.name='Ruby'
AND wptt.taxonomy='post_tag'
AND (wpp.post_content LIKE '%Ruby%'
OR wpp.post_title LIKE '%Ruby%' )
ON DUPLICATE KEY UPDATE
wp_term_relationships.term_taxonomy_id=
wp_term_relationships.term_taxonomy_id

(The ON DUPLICATE code is just a quick hack to tell MySQL to ignore it if you’ve already tagged some posts Ruby by hand.)

4. Hack away. When you’re all done, you’ll want to fix the count in the table with the code below:

UPDATE wp_term_taxonomy wptt
SET wptt.count=
(SELECT count(*)
FROM wp_term_relationships wptr
WHERE wptr.term_taxonomy_id = wptt.term_taxonomy_id
GROUP BY term_taxonomy_id)

Schedules Direct supplies TV/cable schedules for MythTV users

“Schedules Direct is a non-profit organization that provides raw U.S./Canadian tv listing data to Free and Open Source Applications. Those applications then use the data to provide things like PVR functionality, search tools, and private channel grids.” Recently, the Tribune Media Services company Zap2It decided to discontinue their free service that had  provided TV/cable schedules to home hobbiests. Schedules Direct was formed by advocates for the various home-brewed PVRs to step in and supply the content. After negotiations with a number of vendors, they ended up back with TMS as their supplier. In a matter of weeks, the Schedules Direct crew managed to set up the infrastructure to provide a 10-day trial membership, a paid subscription service ($15/3 months initially, with a goal of $20/year or less once they establish the viability of the service) and a working infrastructure. Users of MythTV need to upgrade to the most recent (v 0.20.2 or later) version and change their configuration to use the new service. I switched over the weekend, confirmed I could read the new schedules, and paid up for the first three months. What a great example of the community coming together to supply their own needs.

GNHLUG has had several MythTV meetings, and I anticipate more in the future. Jarod Wilson presented a very popular session at the Merrimack Valley Linux User Group last year, and that lead to an effort by Jarod and maddog and others to run a series of MythTV installfests at NHTI.

Hentzenwerke Moving from Windows to Linux

MySQL-VFP book cover Followers of the Hentzenwerke Publishing empire know that Whil Hentzen has the largest catalog of Visual FoxPro books and an impressive collection of books bridging the gap from the Windows world into the Linux/Free/Open Source world. Whil’s been working for quite some time to put together a book on working with VFP and back-end data servers other than SQL Server. I was one of the many community members who contributed comments, criticisms and ideas to the book, and was honored when Whil chose to designate me as technical editor. Whil Hentzen announces, MySQL Client-Server Applications with Visual FoxPro now on sale:

After far too long a wait, the eagerly awaited companion to our Client/Server Apps with VFP and SQL Server book from years ago is here. The brand new 414 page MySQL Client-Server Applications with Visual FoxPro covers Client-Server apps from the perspective of the hugely popular open-source SQL database, MySQL. Learn how to install, configure MySQL and then connect specifically with VFP. Then get your hands dirty bringing data – both flat files and DBFs – into MySQL databases. Build a variety of user interfaces. Learn about development and deployment scenarios with this multi-platform backend. Each step of the way, real world problems (‘What if the connection fails?’) and potential solutions will be discussed.

The book is on sale only for a short period. Get your copy now!

MonadLUG notes, 10-May-2007, dd and Seth Cohn, Drupal

Ten attendees made it to the May meeting of the Monadnock Valley Linux User Group, held as usual on the second Thursday of the month at the School Administrative Unit #1 offices, Hancock Road, Peterborough.

Bill Freeman presented his thoughts on the Man Page of the Month: dd. Bill provided two pages of notes. Quite the discussion followed obscure and useful things dd could do, such as preserve floppy drive images for posterity, copy music CDs to images for subsequent loopback mount and playing, copy and restore bootblock records and of course read and write tapes.

Seth Cohn was the featured speaker of the night and spoke on Drupal, the content management system. Seth has screenshots of a surprising number and variety of sites that are running on Drupal, presented a bit of Drupal history – seems it’s been around for a long time, and had a fairly stable history – and its current state, with fairly large and active communities of developers and implementors. He covered a bit of the architecture and philosophy of the modular design of Drupal and did the fairly painless install and initial configuration. 9 PM came too soon as there was lots more to see.

Thanks to Seth for presentation, to Bill for MPoM, to Charlie for organizing the meeting and to all for attending and participating.

WordPress 2.2 released

WordPress 2.2 has been released, and it looks like it’s got some pretty cool features:

On behalf of the entire WordPress team, I’m proud and excited to announce the immediate availability of version 2.2 “Getz” for download. This version includes a number of new features, most notably Widgets integration, and over two hundred bug fixes. It’s named in honor of tenor saxophonist Stan Getz.

It also looks like a big enough change not to be an overwrite-and-see-if-it-works update, but rather a carefully planned backup, parallel, switchover, test, test, test process. Look for the upgrade here in the coming weeks…

MonadLUG, 10-May-2007: Seth Cohn presents Drupal

The monthly meeting of the Monadnock region Linux User Group takes place as usual on the second Thursday of the month at the SAU #1 offices in Peterborough. Details and directions here.

Seth Cohn will be presenting Drupal, http://www.drupal.org. I’m looking forward to it. The LUGs have been privileged to see a couple presentations on CMSes: Jonathan Linowes presented Xaraya, and Barrie North Joomla! It’s great that there are som many great choices!

Life After VFP

Robert Jennings posts Yet “Another Life After VFP Thread.” For those not following VFP closely, MS recently announced a confirmation of earlier news that there were no plans for a VFP version 10, and that the VFP scripts in the project known as Sedna would be released under some sort of public license. Poor communications lead to media and Slashdot reports that VFP was to be Open Sourced, sadly not the case.

Robert does a good job of outlining the huge cost in moving a vertical-niche application into another development environment, language and runtime. Most sophisticated specialty applications have person-years of investment built into them, knowledge not easily extracted, transferred or translated to any new environment. Regardless of whether that new environment is Dot Net, Dabo, LAMP, Python or Visual Fred, there will be a huge cost and risk with any enterprise making this switch.

Unlike the Open Source world, when a vendor choses to discontinue a product, developers have little choice but to move along. While many folks point out the upside that the product will likely run for years to come, and a lack of Microsoft official support doesn’t instantly obsolete a product (DOS apps can still be found, after all), there is an immediate slowdown in the custom software market, and a longer-term turning away from the product by customers. Large-scale vertical products have to be operating with 5- and 10-year plans for reinvestment and changes in direction, to ensure they can fund “The Next Big Thing” while continuing to deliver good value to their customers today and tomorrow.

This is not a death knell for the product. The writing has been on the wall for years. But developers with large applications have to be looking around for a new platform.

FoxPro developers always viewed themselves with a bit of “Battlestar Galactica” mythology: a rag-tag crew of self-taught developers from the PC Revolution, they survived the dBASE wars and the implosion of Ashton-Tate. Working under a cruel master who never promoted their product, they persevered. MS’ internal team developing VFP did amazing things on a shoestring budget, introducing a fairly smooth transition from procedural to object-oriented, from developer-guided to event-driven interfaces, from characters to pixels, from local ISAM to RDBMS. The VFP IDE was a remarkable environment in which to develop rich-client, component-based, web-driven or even server-based applications. I will miss it, and look forward to becoming as skilled at my next platform.

Blog, the first five years…

… ended yesterday, and today I start the sixth year of blogging. The first year was blogging on the Perl-based TWiki software, 2003 through 2006 on Radio Userland. This year, I’m using WordPress, on a self-hosting Linux-Apache-MySQL-PHP platform. Wonder what I’ll be running in another five years? It’s been a blast, and I hope it continues to be. Primarily, my blog is my voice online: notes of places I’ve found and want to share (or publicly bookmark so I can find them again), news to pass on, or events on which I comment. Thanks for reading.

GNHLUG MythTV Installfest beta 31-March-2007

GNHLUG recently held an alpha installfest of MythTV, the media-center software (think Free TiVO, jukebox, photo album, more) that runs on Linux. We’re just announcing the beta version in two weeks:

http://wiki.gnhlug.org/twiki2/bin/view/Www/MythFest

This installfest is limited to GNHLUG members and staff and students of the New Hampshire Technical Institute. We hope to open future versions to the public, as we refine the process.

Powered by WordPress. Designed by Woo Themes

This work by Ted Roche is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States.