OpenBSD Journal

databases/sqlports, a Database of Ports

Contributed by mbalmer on from the know-your-ports dept.

Marc Espie, espie@, recently added an sqlite database of ports. Here is some background information:

There's a new port called sqlports in the tree. It's an sqlite database containing most information related to ports in the ports tree.

It's already useful as it is, by using a tool called sqlitebrowser which is also part of the ports tree.

But I expect that enterprising people will run with this and build all kind of interesting dynamic web pages that could present and organize this information.

Some examples

Assuming you've got this database installed, and you're looking at it in sqlitebrowser.
  • How many ports seem to use perl
                                                                                                                    
    SELECT COUNT(PKGPATH) FROM Ports WHERE CONFIGURE_STYLE LIKE '%perl%'                                                 
    
  • All ports in the graphics category
                                                                                                                    
    SELECT DISTINCT PKGPATH FROM Categories WHERE VALUE='graphics'                                                       
    
  • Ports that need GMAKE, but not LIBTOOL
                                                                                                                    
    SELECT DISTINCT PKGPATH FROM Ports WHERE USE_GMAKE=1 AND USE_LIBTOOL IS NULL                                         
    

How it works

There's a new introspection mechanism in the ports tree, the target dumpvars that dumps most variables value to standard output (think of that as an extended describe but not for human consumption.

The output from dumpvars is fed into infrastructure/package/mksqlitedb, a perl script which turns this information into some main table, and does some extra processing for relevant variables (simple object-oriented structure, containing a variable name/class mapping, and using TemplateMethod to handle all kind of variables.

The sqlports port is just the glue that invokes those mechanisms correctly and packages the result.

Design Considerations

People used to mysql or postgresql may wonder about the use of sqlite. Several reasons for that.

  • No heavy-weight setup. sqlite uses plain old text files.
  • Wide-spread support. All relevant languages have sqlite bindings these days.
  • Efficient storage. No need to know how big any field will grow.

I expect that some people will want to create postgresql/mysql databases anyways, and that they will send me relevant changes to adapt mksqlports

(Comments are closed)


Comments
  1. By Jon (85.226.126.231) on

    SQLite does _not_ store the data "plain old text files"...

    Comments
    1. By Anonymous Coward (207.237.33.34) on

      > SQLite does _not_ store the data "plain old text files"...

      and the target is "dump-vars" not "dumpvars"

      Comments
      1. By Anonymous Coward (85.178.68.100) on

        > > SQLite does _not_ store the data "plain old text files"...
        >
        > and the target is "dump-vars" not "dumpvars"

        SQL? Well... lets wait for XML-Stuff wich is the next step in adding much more complexity. ;)

        And then we need a PHP-Frontend... and a C++-Application in the background. :-)

        Comments
        1. By Anonymous Coward (69.70.207.240) on

          > > > SQLite does _not_ store the data "plain old text files"...
          > >
          > > and the target is "dump-vars" not "dumpvars"
          >
          > SQL? Well... lets wait for XML-Stuff wich is the next step in adding much more complexity. ;)
          >
          > And then we need a PHP-Frontend... and a C++-Application in the background. :-)

          So what are you waiting for? :-)

        2. By Anonymous Coward (87.78.124.220) on

          > > > SQLite does _not_ store the data "plain old text files"...
          > >
          > > and the target is "dump-vars" not "dumpvars"
          >
          > SQL? Well... lets wait for XML-Stuff wich is the next step in adding much more complexity. ;)
          >
          > And then we need a PHP-Frontend... and a C++-Application in the background. :-)

          imo sqlite is the best choice for this dataset. changing the storage options is just a diff away.
          what to do with the information is secondary.
          personaly i use the information to expand my ports build env. great to give the information addicted more to consume..

          btw: thx marc! great work.

        3. By corentin (81.56.152.193) on

          > > > SQLite does _not_ store the data "plain old text files"...
          > >
          > > and the target is "dump-vars" not "dumpvars"
          >
          > SQL? Well... lets wait for XML-Stuff wich is the next step in adding much more complexity. ;)

          SQL sucks; querying a database directly in C or Perl is obviously much less complex, right?

          The set of requirements is complex (i.e. the ability to do powerful queries on the database), not the implementation (which uses technologies designed for such a task).

        4. By Marc Espie (213.41.185.88) espie@openbsd.org on

          I think you guys are missing some important points.

          - this is infrastructure work. You can reuse dump-vars to do whatever
          you want with the variable values. The mksqlitedb script was written over one afternoon. It is very simple work. There's no point in not reusing existing tools.

          - Yes, you could store that information into any kind of data structure. After all, you don't create anything that's new. All that info is already in the ports tree.

          - We do not intend the ports tree to become dependent upon this tool. This is just simple information that can be used to do other things. Like a web site. I could probably make a simple web site out of this database and HTML::Mason in one day or two. It's really that simple. And there are people out there who will have fun doing this kind of thing.

          In all, there is no point in coming up with a smarter design for this. The tools are out there. Why code it again in C or perl ? Again, we're not talking about a basic tool, but about presentation stuff for end-users. Who cares if you need to install sqlite ? It's real fast to compile, and it even has a nice license (public domain).

      2. By Marc Espie (213.41.185.88) espie@openbsd.org on

        > > SQLite does _not_ store the data "plain old text files"...
        >
        > and the target is "dump-vars" not "dumpvars"

        Yes to both. Those are details.

        What I meant is, SQLite databases are plain files, not complex
        database structures, with holes, directories or devoted partitions.

  2. By Anonymous Coward (69.243.48.238) on

    Thank for this! It looks like it could be fun to play with.

Latest Articles

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]