SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
DBDI
for Perl6
In

2007
I said...
Database interfaces
 for open source
 languages suck
They’re all limited

 They’re all different

They’re all duplicating
 development effort
We need

a common database driver API

    for Perl 6 and Parrot
But what?
Mature, Stable, Functional,
       Object Oriented

Well documented, with a test suite

 Well known to a wide user base

Well known to driver developers
JDBC
No, not Java, just the JDBC API

  The class and method names,
          the semantics
       the documentation
           the test suite
Actually, not plain JDBC

Sanitize the worst influences of Java

Easier to use for dynamic languages
Your Code
DBI v2 API

                      DBI
DBDI API

                      DBD



             Database Client Library
NO JDBC FOR THIS!

                    Your Code
 DBI v2 API

                       DBI
 DBDI API

                       DBD


USE JDBC      Database Client Library
FOR THIS
How?
java2perl6api

  Generates Perl 6 Role modules that
mirror the API of specified Java Classes

      Originally a GSoC Project
        by Phil Crow in 2007

     http://github.com/timbunce/java2perl6
Recurses into types used Maps Java types to Perl6
   $ java2perl6api --add_types jdbclib-typemap --outdir jdbclib java.sql.DriverManager
   perl6: Rakudo Perl 6, version 2010.07-39-gac8a2ae built on parrot 2.6.0 r48152
   loading java.sql.DriverManager
   loading . java.sql.Connection
   loading . . java.sql.Array
   loading . . . java.sql.ResultSet
   loading . . . . java.io.Reader
   loading . . . . java.sql.Date
   loading . . . . java.sql.Ref
   loading . . . . java.sql.ResultSetMetaData
   loading . . . . . java.sql.Wrapper
   loading . . . . java.sql.RowId
   loading . . . . java.sql.SQLWarning
   loading . . . . . java.sql.SQLException
   loading . . . . java.sql.Statement
   ...
   wrote jdbclib/java/lang/Enum.pm6 - class java.lang.Enum
   wrote jdbclib/java/sql/CallableStatement.pm6 - interface java.sql.CallableStatement
   ...
   compiling jdbclib/java/sql/SQLException.pm6 - class java.sql.SQLException
   compiling jdbclib/java/sql/Statement.pm6 - interface java.sql.Statement
   ...


                Compiles to .pir for validation and speed
public interface java.sql.Statement extends java.sql.Wrapper {

      public static final int SUCCESS_NO_INFO;
      public static final int EXECUTE_FAILED;

      public abstract boolean execute(java.lang.String)
         throws java.sql.SQLException;

      public abstract boolean execute(java.lang.String, int)
         throws java.sql.SQLException;

      ...
}
role java::sql::Statement does java::sql::Wrapper   {

    method SUCCESS_NO_INFO (--> Int) is export { ... }
    method EXECUTE_FAILED (--> Int) is export { ... }

    multi method execute (
        Str $v1,
    --> Bool
    ) { ... } # throws java.sql.SQLException

    multi method execute (
        Str $v1,
        Int $v2,
    --> Bool
    ) { ... } # throws java.sql.SQLException

    ...
}
2009
MiniDBI (formerly “FakeDBI”)

  “a tiny subset of DBI in Perl 6”
     started by Martin Berends

  “hopefully be obsoleted ASAP”

has PostgreSQL and MySQL drivers
2010
DBDI

A database driver manager and driver
 implementation framework in Perl 6

Uses the roles generated by running
java2perl6api java.sql.DriverManager


      http://github.com/timbunce/DBDI
It Runs!

   A working PostgreSQL driver
       is included in DBDI

It’s very minimal today (August 2010)
 but it only took a few hours to write
#           --- DBDI usage example ---
use v6;

use DBDI;
use DBDI::pglibpq;

my $url = @*ARGS.shift || prompt "Enter a 'dbdi:driver:...' URL: ";

my $con = DBDI::DriverManager.getConnection($url, 'testuser', 'testpass');

while prompt 'SQL: ' -> $sql {

    my $result = $con.createStatement.executeQuery($sql);
    my $meta   = $result.getMetaData;

    my @names = map { $meta.getColumnLabel($_) }, 1..$meta.getColumnCount;
    say @names.join(", ");

    while ( $result.next ) {
        my @row = map { $result.getString($_) }, 1..@names.elems;
        say @row.join(", ");
    }
}
CURRENT SITUATION
                         Your Code




         MiniDBI
                                           DBDI



   MiniDBI Drivers
                                      DBDI Drivers




                     DB Client Libs
 BASIC BUT                                          BARE
FUNCTIONAL                                        SKELETON
Next steps?
Build up a class/role hirearchy borrowing
    from open source JDBC drivers

Separate driver-specific logic from driver-
  independant logic to make it easy to
           implement drivers

   Establish infrastructure for logging,
              exceptions etc.
SOME POINT IN THE FUTURE
                              Your Code

MiniDBI Tests



                MiniDBI




                                                              Framework
                                                 DBDI




                                                                Driver
       MiniDBI Drivers
  MiniDBI DBDI Driver                      DBDI Drivers


                                                    SUCK BRAINZ
                                                   FROM MiniDBI
  TRANSITION
                          DB Client Libs           DRIVERS INTO
& TEST ENABLER                                     DBDI DRIVERS
SOME POINT IN THE FUTURE
                      Your Code




      MiniDBI




                                                      Framework
                                         DBDI




                                                        Driver
MiniDBI Drivers                    DBDI Drivers




                  DB Client Libs
                                          Also ADD a DRIVER
                                         to access Perl5 DBI
                                           using blitzkost
SOME POINT FURTHER IN THE FUTURE

    Your Code          JDBC Test Suite



  DBI v1/v2/v3/*       Sufficient Magic



      DBDI




                            Framework
                              Driver
DBDI Drivers



DB Client Libs
Interested?

    Come and join in!

    dbdi-dev@perl.org

#dbdi on irc.freenode.org

Más contenido relacionado

La actualidad más candente

Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
Ganesh Kondal
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
deimos
 
Ruby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraRuby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybara
Bindesh Vijayan
 

La actualidad más candente (20)

Java 9, JShell, and Modularity
Java 9, JShell, and ModularityJava 9, JShell, and Modularity
Java 9, JShell, and Modularity
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 
Open Social Summit Korea
Open Social Summit KoreaOpen Social Summit Korea
Open Social Summit Korea
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
 
Refactoring to SOLID Code
Refactoring to SOLID CodeRefactoring to SOLID Code
Refactoring to SOLID Code
 
What's New in NetBeans IDE 7.x
What's New in NetBeans IDE 7.xWhat's New in NetBeans IDE 7.x
What's New in NetBeans IDE 7.x
 
Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)
 
Just enough app server
Just enough app serverJust enough app server
Just enough app server
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React App
 
The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015The curious Life of JavaScript - Talk at SI-SE 2015
The curious Life of JavaScript - Talk at SI-SE 2015
 
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 201450 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
Ruby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraRuby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybara
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshop
 

Destacado (7)

PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012
 
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
 
Graphic visualization
Graphic visualizationGraphic visualization
Graphic visualization
 
Perl Dist::Surveyor 2011
Perl Dist::Surveyor 2011Perl Dist::Surveyor 2011
Perl Dist::Surveyor 2011
 
Perl-Critic
Perl-CriticPerl-Critic
Perl-Critic
 
Perl Tidy Perl Critic
Perl Tidy Perl CriticPerl Tidy Perl Critic
Perl Tidy Perl Critic
 
Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.key
 

Similar a Perl6 DBDI YAPC::EU 201008

jdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptxjdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptx
ssuser8878c1
 

Similar a Perl6 DBDI YAPC::EU 201008 (20)

Perl 6 DBDI 201007 (OUTDATED, see 201008)
Perl 6 DBDI 201007 (OUTDATED, see 201008)Perl 6 DBDI 201007 (OUTDATED, see 201008)
Perl 6 DBDI 201007 (OUTDATED, see 201008)
 
chapter 5 java.pptx
chapter 5  java.pptxchapter 5  java.pptx
chapter 5 java.pptx
 
Java database programming with jdbc
Java database programming with jdbcJava database programming with jdbc
Java database programming with jdbc
 
Jdbc_ravi_2016
Jdbc_ravi_2016Jdbc_ravi_2016
Jdbc_ravi_2016
 
jdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptxjdbc-130913021409-phpapp01000988www.pptx
jdbc-130913021409-phpapp01000988www.pptx
 
jdbc document
jdbc documentjdbc document
jdbc document
 
Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
 
jdbc
jdbcjdbc
jdbc
 
Introduction of java jdbc
Introduction of java jdbcIntroduction of java jdbc
Introduction of java jdbc
 
Introduction of java jdbc
Introduction of java jdbcIntroduction of java jdbc
Introduction of java jdbc
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Jdbc drivers
Jdbc driversJdbc drivers
Jdbc drivers
 
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
 jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
 
Unit 5-jdbc2
Unit 5-jdbc2Unit 5-jdbc2
Unit 5-jdbc2
 
Chapter_4_-_JDBC[1].pptx
Chapter_4_-_JDBC[1].pptxChapter_4_-_JDBC[1].pptx
Chapter_4_-_JDBC[1].pptx
 

Más de Tim Bunce

Más de Tim Bunce (13)

Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406
 
Perl Memory Use - LPW2013
Perl Memory Use - LPW2013Perl Memory Use - LPW2013
Perl Memory Use - LPW2013
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12
 
Perl Memory Use 201209
Perl Memory Use 201209Perl Memory Use 201209
Perl Memory Use 201209
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )Perl Memory Use 201207 (OUTDATED, see 201209 )
Perl Memory Use 201207 (OUTDATED, see 201209 )
 
PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0PL/Perl - New Features in PostgreSQL 9.0
PL/Perl - New Features in PostgreSQL 9.0
 
DBI Advanced Tutorial 2007
DBI Advanced Tutorial 2007DBI Advanced Tutorial 2007
DBI Advanced Tutorial 2007
 
Perl Myths 200909
Perl Myths 200909Perl Myths 200909
Perl Myths 200909
 
DashProfiler 200807
DashProfiler 200807DashProfiler 200807
DashProfiler 200807
 
DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007DBI for Parrot and Perl 6 Lightning Talk 2007
DBI for Parrot and Perl 6 Lightning Talk 2007
 
DBD::Gofer 200809
DBD::Gofer 200809DBD::Gofer 200809
DBD::Gofer 200809
 
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
 
Perl Myths 200802 with notes (OUTDATED, see 200909)
Perl Myths 200802 with notes (OUTDATED, see 200909)Perl Myths 200802 with notes (OUTDATED, see 200909)
Perl Myths 200802 with notes (OUTDATED, see 200909)
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Perl6 DBDI YAPC::EU 201008

  • 3. Database interfaces for open source languages suck
  • 4. They’re all limited They’re all different They’re all duplicating development effort
  • 5. We need a common database driver API for Perl 6 and Parrot
  • 7. Mature, Stable, Functional, Object Oriented Well documented, with a test suite Well known to a wide user base Well known to driver developers
  • 8. JDBC No, not Java, just the JDBC API The class and method names, the semantics the documentation the test suite
  • 9. Actually, not plain JDBC Sanitize the worst influences of Java Easier to use for dynamic languages
  • 10. Your Code DBI v2 API DBI DBDI API DBD Database Client Library
  • 11. NO JDBC FOR THIS! Your Code DBI v2 API DBI DBDI API DBD USE JDBC Database Client Library FOR THIS
  • 12. How?
  • 13. java2perl6api Generates Perl 6 Role modules that mirror the API of specified Java Classes Originally a GSoC Project by Phil Crow in 2007 http://github.com/timbunce/java2perl6
  • 14. Recurses into types used Maps Java types to Perl6 $ java2perl6api --add_types jdbclib-typemap --outdir jdbclib java.sql.DriverManager perl6: Rakudo Perl 6, version 2010.07-39-gac8a2ae built on parrot 2.6.0 r48152 loading java.sql.DriverManager loading . java.sql.Connection loading . . java.sql.Array loading . . . java.sql.ResultSet loading . . . . java.io.Reader loading . . . . java.sql.Date loading . . . . java.sql.Ref loading . . . . java.sql.ResultSetMetaData loading . . . . . java.sql.Wrapper loading . . . . java.sql.RowId loading . . . . java.sql.SQLWarning loading . . . . . java.sql.SQLException loading . . . . java.sql.Statement ... wrote jdbclib/java/lang/Enum.pm6 - class java.lang.Enum wrote jdbclib/java/sql/CallableStatement.pm6 - interface java.sql.CallableStatement ... compiling jdbclib/java/sql/SQLException.pm6 - class java.sql.SQLException compiling jdbclib/java/sql/Statement.pm6 - interface java.sql.Statement ... Compiles to .pir for validation and speed
  • 15. public interface java.sql.Statement extends java.sql.Wrapper { public static final int SUCCESS_NO_INFO; public static final int EXECUTE_FAILED; public abstract boolean execute(java.lang.String) throws java.sql.SQLException; public abstract boolean execute(java.lang.String, int) throws java.sql.SQLException; ... }
  • 16. role java::sql::Statement does java::sql::Wrapper { method SUCCESS_NO_INFO (--> Int) is export { ... } method EXECUTE_FAILED (--> Int) is export { ... } multi method execute ( Str $v1, --> Bool ) { ... } # throws java.sql.SQLException multi method execute ( Str $v1, Int $v2, --> Bool ) { ... } # throws java.sql.SQLException ... }
  • 17. 2009
  • 18. MiniDBI (formerly “FakeDBI”) “a tiny subset of DBI in Perl 6” started by Martin Berends “hopefully be obsoleted ASAP” has PostgreSQL and MySQL drivers
  • 19. 2010
  • 20. DBDI A database driver manager and driver implementation framework in Perl 6 Uses the roles generated by running java2perl6api java.sql.DriverManager http://github.com/timbunce/DBDI
  • 21. It Runs! A working PostgreSQL driver is included in DBDI It’s very minimal today (August 2010) but it only took a few hours to write
  • 22. # --- DBDI usage example --- use v6; use DBDI; use DBDI::pglibpq; my $url = @*ARGS.shift || prompt "Enter a 'dbdi:driver:...' URL: "; my $con = DBDI::DriverManager.getConnection($url, 'testuser', 'testpass'); while prompt 'SQL: ' -> $sql { my $result = $con.createStatement.executeQuery($sql); my $meta = $result.getMetaData; my @names = map { $meta.getColumnLabel($_) }, 1..$meta.getColumnCount; say @names.join(", "); while ( $result.next ) { my @row = map { $result.getString($_) }, 1..@names.elems; say @row.join(", "); } }
  • 23. CURRENT SITUATION Your Code MiniDBI DBDI MiniDBI Drivers DBDI Drivers DB Client Libs BASIC BUT BARE FUNCTIONAL SKELETON
  • 25. Build up a class/role hirearchy borrowing from open source JDBC drivers Separate driver-specific logic from driver- independant logic to make it easy to implement drivers Establish infrastructure for logging, exceptions etc.
  • 26. SOME POINT IN THE FUTURE Your Code MiniDBI Tests MiniDBI Framework DBDI Driver MiniDBI Drivers MiniDBI DBDI Driver DBDI Drivers SUCK BRAINZ FROM MiniDBI TRANSITION DB Client Libs DRIVERS INTO & TEST ENABLER DBDI DRIVERS
  • 27. SOME POINT IN THE FUTURE Your Code MiniDBI Framework DBDI Driver MiniDBI Drivers DBDI Drivers DB Client Libs Also ADD a DRIVER to access Perl5 DBI using blitzkost
  • 28. SOME POINT FURTHER IN THE FUTURE Your Code JDBC Test Suite DBI v1/v2/v3/* Sufficient Magic DBDI Framework Driver DBDI Drivers DB Client Libs
  • 29. Interested? Come and join in! dbdi-dev@perl.org #dbdi on irc.freenode.org