{
    "mode": "perldoc",
    "parameter": "DBD::File::HowTo",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/DBD%3A%3AFile%3A%3AHowTo/json",
    "generated": "2026-06-16T00:39:36Z",
    "synopsis": "perldoc DBD::File::HowTo\nperldoc DBI\nperldoc DBI::DBD\nperldoc DBD::File::Developers\nperldoc DBI::DBD::SqlEngine::Developers\nperldoc DBI::DBD::SqlEngine\nperldoc SQL::Eval\nperldoc DBI::DBD::SqlEngine::HowTo\nperldoc SQL::Statement::Embed\nperldoc DBD::File\nperldoc DBD::File::HowTo\nperldoc DBD::File::Developers",
    "sections": {
        "NAME": {
            "content": "DBD::File::HowTo - Guide to create DBD::File based driver\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "perldoc DBD::File::HowTo\nperldoc DBI\nperldoc DBI::DBD\nperldoc DBD::File::Developers\nperldoc DBI::DBD::SqlEngine::Developers\nperldoc DBI::DBD::SqlEngine\nperldoc SQL::Eval\nperldoc DBI::DBD::SqlEngine::HowTo\nperldoc SQL::Statement::Embed\nperldoc DBD::File\nperldoc DBD::File::HowTo\nperldoc DBD::File::Developers\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This document provides a step-by-step guide, how to create a new \"DBD::File\" based DBD. It\nexpects that you carefully read the DBI documentation and that you're familiar with DBI::DBD and\nhad read and understood DBD::ExampleP.\n\nThis document addresses experienced developers who are really sure that they need to invest time\nwhen writing a new DBI Driver. Writing a DBI Driver is neither a weekend project nor an easy job\nfor hobby coders after work. Expect one or two man-month of time for the first start.\n\nThose who are still reading, should be able to sing the rules of \"CREATING A NEW DRIVER\" in\nDBI::DBD.\n\nOf course, DBD::File is a DBI::DBD::SqlEngine and you surely read DBI::DBD::SqlEngine::HowTo\nbefore continuing here.\n",
            "subsections": []
        },
        "CREATING DRIVER CLASSES": {
            "content": "Do you have an entry in DBI's DBD registry? For this guide, a prefix of \"foo\" is assumed.\n",
            "subsections": [
                {
                    "name": "Sample Skeleton",
                    "content": "package DBD::Foo;\n\nuse strict;\nuse warnings;\nuse vars qw(@ISA $VERSION);\nuse base qw(DBD::File);\n\nuse DBI ();\n\n$VERSION = \"0.001\";\n\npackage DBD::Foo::dr;\n\nuse vars qw(@ISA $impdatasize);\n\n@ISA = qw(DBD::File::dr);\n$impdatasize = 0;\n\npackage DBD::Foo::db;\n\nuse vars qw(@ISA $impdatasize);\n\n@ISA = qw(DBD::File::db);\n$impdatasize = 0;\n\npackage DBD::Foo::st;\n\nuse vars qw(@ISA $impdatasize);\n\n@ISA = qw(DBD::File::st);\n$impdatasize = 0;\n\npackage DBD::Foo::Statement;\n\nuse vars qw(@ISA);\n\n@ISA = qw(DBD::File::Statement);\n\npackage DBD::Foo::Table;\n\nuse vars qw(@ISA);\n\n@ISA = qw(DBD::File::Table);\n\n1;\n\nTiny, eh? And all you have now is a DBD named foo which will be able to deal with temporary\ntables, as long as you use SQL::Statement. In DBI::SQL::Nano environments, this DBD can do\nnothing.\n"
                },
                {
                    "name": "Start over",
                    "content": "Based on DBI::DBD::SqlEngine::HowTo, we're now having a driver which could do basic things. Of\ncourse, it should now derive from DBD::File instead of DBI::DBD::SqlEngine, shouldn't it?\n\nDBD::File extends DBI::DBD::SqlEngine to deal with any kind of files. In principle, the only\nextensions required are to the table class:\n\npackage DBD::Foo::Table;\n\nsub bootstraptablemeta\n{\nmy ( $self, $dbh, $meta, $table ) = @;\n\n# initialize all $meta attributes which might be relevant for\n# file2table\n\nreturn $self->SUPER::bootstraptablemeta($dbh, $meta, $table);\n}\n\nsub inittablemeta\n{\nmy ( $self, $dbh, $meta, $table ) = @;\n\n# called after $meta contains the results from file2table\n# initialize all missing $meta attributes\n\n$self->SUPER::inittablemeta( $dbh, $meta, $table );\n}\n\nIn case \"DBD::File::Table::openfile\" doesn't open the files as the driver needs that, override\nit!\n\nsub openfile\n{\nmy ( $self, $meta, $attrs, $flags ) = @;\n# ensure that $meta->{fdontopen} is set\n$self->SUPER::openfile( $meta, $attrs, $flags );\n# now do what ever needs to be done\n}\n\nCombined with the methods implemented using the SQL::Statement::Embed guide, the table is full\nworking and you could try a start over.\n"
                },
                {
                    "name": "User comfort",
                    "content": "\"DBD::File\" since 0.39 consolidates all persistent meta data of a table into a single structure\nstored in \"$dbh->{fmeta}\". With \"DBD::File\" version 0.41 and \"DBI::DBD::SqlEngine\" version\n0.05, this consolidation moves to DBI::DBD::SqlEngine. It's still the \"$dbh->{$drvprefix .\n\"meta\"}\" attribute which cares, so what you learned at this place before, is still valid.\n\nsub initvalidattributes\n{\nmy $dbh = $[0];\n\n$dbh->SUPER::initvalidattributes ();\n\n$dbh->{foovalidattrs} = { ... };\n$dbh->{fooreadonlyattrs} = { ...  };\n\n$dbh->{foometa} = \"footables\";\n\nreturn $dbh;\n}\n\nSee updates at \"User comfort\" in DBI::DBD::SqlEngine::HowTo.\n"
                },
                {
                    "name": "Testing",
                    "content": "Now you should have your own DBD::File based driver. Was easy, wasn't it? But does it work well?\nProve it by writing tests and remember to use dbdeditmmattribs from DBI::DBD to ensure\ntesting even rare cases.\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "This guide is written by Jens Rehsack. DBD::File is written by Jochen Wiedmann and Jeff Zucker.\n\nThe module DBD::File is currently maintained by\n\nH.Merijn Brand < h.m.brand at xs4all.nl > and Jens Rehsack < rehsack at googlemail.com >\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "Copyright (C) 2010 by H.Merijn Brand & Jens Rehsack\n\nAll rights reserved.\n\nYou may freely distribute and/or modify this module under the terms of either the GNU General\nPublic License (GPL) or the Artistic License, as specified in the Perl README file.\n",
            "subsections": []
        }
    },
    "summary": "DBD::File::HowTo - Guide to create DBD::File based driver",
    "flags": [],
    "examples": [],
    "see_also": []
}