Client applications

How to work with Ethereum data in some example applications and programming languages:

Microsoft Access

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Access.

  2. Configure an ODBC data source.

  3. Open your Microsoft Access database.

  4. Choose Create > Query Design.

  5. Choose Close to dismiss the Close Table dialog box.

  6. Choose Pass-Through.

  7. In the property sheet, click the down arrow in the ODBC Connect Str field value.

  8. In the Select Data Source dialog box, choose the Machine Data Source tab.

  9. Choose your Easysoft ODBC-Ethereum Driver data source from the list, and then choose OK.

  10. Choose No when prompted whether to save the password in the connection string.

  11. In the Query Pane, enter an SQL query. For example:

    SELECT * FROM getBlockByNumber WHERE blockNumber = 'latest' AND transactionDetailsFlag = false
  12. Choose the Run button.

  13. Save your new query.

Microsoft Excel

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Excel.

  2. Configure an ODBC data source.

  3. Choose one of the following ways to work with your Ethereum data in Excel.

Data Connection Wizard

  1. Choose Data > Get Data > From Other Sources > From ODBC.

  2. Choose your Easysoft ODBC-Ethereum Driver data source from the list, and then choose OK.

  3. Enter the user name and password for your data store if applicable, otherwise, enter any text string to get past this stage. Choose Next.

  4. Do one of the following:

    • If you don’t want to filter your results by column and your Ethereum table has no mandatory fields (blobBaseFee, blockNumber, chainId, gasPrice, maxPriorityFeePerGas, newBlockFilter, protocolVersion, syncing) choose the table that contains the data you want to retrieve, and then choose Load.

      -Or-

    • If you do want to filter your results by column and your Ethereum table is not listed in the previous bullet, choose the table you want. Ignore any errors about mandatory fields. Choose Transform data. In the Power Query Editor, in the formula bar, replace the existing formula with:

      Odbc.Query("dsn=Ethereum", "SQL query")

      For example:

      Odbc.Query("dsn=Ethereum", "SELECT blobGasUsed FROM getBlockByNumber WHERE blockNumber = 'latest' AND transactionDetailsFlag = false")

      Choose the "tick" button. Choose Close and load.

Microsoft Query

  1. Choose Data > Get Data > From Other Sources > From Microsoft Query.

  2. In the Choose Data Source dialog box, choose your Ethereum data source from the list, and then choose OK.

  3. Do one of the following:

    • If you don’t want to filter your results by column and your Ethereum table has no mandatory fields (blobBaseFee, blockNumber, chainId, gasPrice, maxPriorityFeePerGas, newBlockFilter, protocolVersion, syncing) choose the result column and then choose the > button to move this column to the Columns in your query list.

      -Or-

    • If you do want to filter your results by column and your Ethereum table is not listed in the previous bullet, choose the columns you want in the query results and the columns that you want to filter the data by. For example, if you wanted to find out the total used gas by all transactions in the latest block, under getBlockByNumber, choose blobGasUsed (the result set you want), blockNumber and transactionDetailsFlag (mandatory fields for the table).

  4. If you want to return a subset of the data, use the Filter Data screen to filter the results of your query (this is the equivalent of a SQL WHERE clause), and then choose Next. For the example given in the previous step, choose blockNumber, then choose equals, and then enter latest. Choose transactionDetailsFlag, then choose equals, and then enter true. Choose Next

  5. If you want to change the sort order of your data, use the Sort Order screen to sort the results of your query (this is the equivalent of a SQL ORDER BY clause), and then choose Next. Choose Finish to return your Ethereum data to Excel.

PowerPivot

  1. On the PowerPivot tab, choose Manage.

  2. In the PowerPivot window, choose Get External Data > From Other Sources.

  3. In the Connect to a Data Source list, choose Others (OLEDB/ODBC)

  4. In the Specify a Connection screen, enter a name for your connection in the space provided. Then choose Build.

  5. In the Data Link Properties box, choose your Easysoft ODBC-Ethereum Driver data source from the list, and then choose OK.

  6. Choose Next.

  7. Choose how to import your Ethereum data and then choose Finish.

    Do one of the following:

    • If you don’t want to filter your results by column and your Ethereum table has no mandatory fields (blobBaseFee, blockNumber, chainId, gasPrice, maxPriorityFeePerGas, newBlockFilter, protocolVersion, syncing) choose Select from a list of tables and views to choose the data to import. Then choose Next. Select your tables and then choose Finish.

      -Or-

    • If you do want to filter your results by column and your Ethereum table is not listed in the previous bullet, choose Write a query that will specify the data to import. Then choose Next. Enter your SQL query in the space provided. For example:

      SELECT blobGasUsed FROM getBlockByNumber WHERE blockNumber = 'latest' AND transactionDetailsFlag = true

      Choose Finish.

  8. Save your Power Pivot.

Microsoft Power BI

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Power BI Desktop.

  2. Configure an ODBC data source.

  3. In Power BI Desktop, choose Get data from another source.

  4. In the Get Data dialog box, choose ODBC, and then choose Connect.

  5. In the From ODBC dialog box, choose your Ethereum data source, and then choose Advanced Options.

  6. In the SQL statement box, enter:

    SELECT transactions FROM getBlockByNumber WHERE '0x1531dbb' AND transactionDetailsFlag = false
  7. Choose OK.

  8. Choose Load

  9. Under Data >>, expand your new query, and then choose Transactions.

Tableau Desktop

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Access.

  2. Configure an ODBC data source.

  3. In Tableau Desktop, choose Other Databases (ODBC).

  4. In the Other Databases (ODBC) dialog box, choose your Easysoft ODBC-Ethereum Driver data source.

  5. Choose Connect, and then choose Sign in

  6. Select a database from the Database list.

  7. Double-click New Custom SQL.

  8. In the Edit Custom SQL box, enter an SQL query, and the choose OK.

    For example:

    SELECT blockNumber, [timestamp], blobGasUsed  FROM getBlockByNumber WHERE blockNumber = '0x152fdd8' AND transactionDetailsFlag = false
  9. Choose Update Now.

Microsoft SQL Server

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as SQL Server.

  2. Configure an ODBC data source.

  3. In Microsoft SQL Server Management Studio, connect to the SQL Server instance you want to create the linked server against.

    You need to log on with an account that is a member of the SQL Server sysadmin fixed server role to create a linked server.

  4. Right-click Server Objects. From the pop-up menu choose New > Linked Server.

  5. In the Linked server box, enter "Ethereum".

  6. From the Provider list, choose Microsoft OLE DB Provider for ODBC drivers.

  7. In the Data source box, enter the name of your Ethereum data source, and then choose OK.

    SQL Server verifies the linked server by testing the connection.

    • If you get the error "Specified driver could not be loaded due to system error 126: The specified module could not be found," choose Yes when prompted whether to keep the linked server. You need to restart your SQL Server instance before you can use the linked server. If SQL Server was already running when you installed the Easysoft ODBC-Ethereum Driver, it will not have the latest version of the System Path environment variable. The Easysoft ODBC-Ethereum Driver Setup program adds entries for the driver to the System Path. Restarting the instance makes these changes available to SQL Server, allowing it to load the Easysoft ODBC-Ethereum Driver.

    • If you made a mistake when specifying the Easysoft ODBC-Ethereum Driver, you get the error "Data source name not found and no default driver specified." If you get this error, choose No when prompted whether to keep the linked server and edit the value in the Data source box.

  8. You can query your Easysoft ODBC-Ethereum Driver data either by using a:

    • Pass-through query in an OPENQUERY function. For example:

      SELECT * FROM OPENQUERY([Ethereum], 'SELECT * FROM getBlockByNumber WHERE blockNumber = ''latest'' AND transactionDetailsFlag = false')
      
      DECLARE @Result NVARCHAR(MAX)
      SET @Result = (SELECT * FROM OPENQUERY(Ethereum, 'SELECT transactions FROM getBlockByNumber WHERE blockNumber = ''latest'' AND transactionDetailsFlag = false'));
      SELECT * FROM OpenJson(@Result);

      SQL Server sends pass-through queries as uninterpreted query strings to the Ethereum. This means that SQL Server does not apply any kind of logic to the query or try to estimate what that query will do.

Oracle

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Oracle.

  2. Configure an ODBC data source.

  3. Follow the instructions for your Oracle platform.

Connecting Ethereum to Oracle on Windows

  1. Create a DG4ODBC init file on your Oracle machine. To do this, change to the %ORACLE_HOME%\hs\admin directory. Create a copy of the file initdg4odbc.ora. Name the new file initEthereum.ora.

    In these instructions, replace %ORACLE_HOME% with the location of your Oracle HOME directory. For example, C:\app\product\21c\homes\OraDB21Home1.
  2. Ensure these parameters and values are present in your init file:

    HS_FDS_CONNECT_INFO = "Ethereum"

    Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.

  3. Comment out the line that enables DG4ODBC tracing. For example:

    #HS_FDS_TRACE_LEVEL = <trace_level>
  4. Add an entry to %ORACLE_HOME%\network\admin\listener.ora that creates a SID_NAME for DG4ODBC. For example:

    SID_LIST_LISTENER =
     (SID_LIST =
       (SID_DESC=
         (SID_NAME=Ethereum)
         (ORACLE_HOME=%ORACLE_HOME%)
         (PROGRAM=dg4odbc)
       )
     )
  5. Add a DG4ODBC entry to %ORACLE_HOME%\network\admin\tnsnames.ora that specifies the SID_NAME created in the previous step. For example:

    Ethereum =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = oracle_host)(PORT = 1521))
        (CONNECT_DATA =
          (SID = Ethereum)
        )
        (HS = OK)
      )

    Replace oracle_host with the host name of your Oracle machine.

  6. Start (or restart) the Oracle Listener:

    cd %ORACLE_HOME%\bin
    lsnrctl stop
    lsnrctl start
  7. Connect to your Oracle database in SQL*Plus.

  8. In SQL*Plus, create a database link for Ethereum. For example:

    CREATE PUBLIC DATABASE LINK EthereumLink
        CONNECT TO "dbuser" IDENTIFIED BY "dbpassword"
        USING 'Ethereum';

    Replace dbuser and dbpassword with your backend user name and password, if applicable.

  9. Try working with your Ethereum data. For example:

    SELECT * FROM blobBaseFee@EthereumLink;

    Alternatively, use a SQL passthrough query:

    SET SERVEROUTPUT ON
    
    DECLARE
      v_cursor NUMBER;
      v_rows_fetched NUMBER;
      v_col1 VARCHAR2(255);
    BEGIN
      v_cursor := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@EthereumLink;
    
      DBMS_HS_PASSTHROUGH.PARSE@EthereumLink(v_cursor, 'SELECT blobGasUsed FROM getBlockByNumber WHERE blockNumber = ''latest'' AND transactionDetailsFlag = true');
    
      -- Fetch rows from the result set
      LOOP
        v_rows_fetched := DBMS_HS_PASSTHROUGH.FETCH_ROW@EthereumLink(v_cursor);
        EXIT WHEN v_rows_fetched = 0;
    
        DBMS_HS_PASSTHROUGH.GET_VALUE@EthereumLink(v_cursor, 1, v_col1);
        DBMS_OUTPUT.PUT_LINE('Gas used: ' || v_col1);
      END LOOP;
    
      DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@EthereumLink(v_cursor);
    EXCEPTION
      WHEN OTHERS THEN
        DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@EthereumLink(v_cursor);
        RAISE;
    END;
    /

Notes

  • If you have problems connecting to Ethereum from Oracle, enable DG4ODBC tracing and check the trace files written to the %ORACLE_HOME%\hs\trace directory. To enable DG4ODBC tracing, add the line HS_FDS_TRACE_LEVEL = DEBUG to initEthereum.ora and then start or restart the Oracle listener. If the trace directory does not exist, create it.

  • If you enable ODBC Driver Manager tracing, but do not get a log file in the location you specify, try looking in the top-level folder (for example, C:\SQL.log). Alternatively, in ODBC Data Source Administrator, change the trace file location to the Windows TEMP directory.

Connecting Ethereum to Oracle on Linux and UNIX

  1. Create a DG4ODBC init file on your Oracle machine. To do this, change to the $ORACLE_HOME\hs\admin directory. Create a copy of the file initdg4odbc.ora. Name the new file initEthereum.ora.

    In these instructions, replace $ORACLE_HOME with the location of your Oracle HOME directory. For example, /u01/app/oracle/product/21c/dbhome_1.
  2. Ensure these parameters and values are present in your init file:

    HS_FDS_CONNECT_INFO = "Ethereum"

    Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.

  3. Comment out the line that enables DG4ODBC tracing. For example:

    #HS_FDS_TRACE_LEVEL = <trace_level>
  4. Add an entry to $ORACLE_HOME/network/admin/listener.ora that creates a SID_NAME for DG4ODBC. For example:

    SID_LIST_LISTENER =
     (SID_LIST =
       (SID_DESC=
         (SID_NAME=Ethereum)
         (ORACLE_HOME=$ORACLE_HOME)
         (PROGRAM=dg4odbc)
         (ENVS=LD_LIBRARY_PATH = /usr/local/easysoft/unixODBC/lib:
                /usr/local/easysoft/lib)
       )
     )

    Replace oracle_home_directory with the value of $ORACLE_HOME. For example, /u01/app/oracle/product/21c/dbhome_1.

  5. Add a DG4ODBC entry to $ORACLE_HOME/network/admin/tnsnames.ora that specifies the SID_NAME created in the previous step. For example:

    Ethereum =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = oracle_host)(PORT = 1521))
        (CONNECT_DATA =
          (SID = Ethereum)
        )
        (HS = OK)
      )

    Replace oracle_host with the host name of your Oracle machine.

  6. Start (or restart) the Oracle Listener:

    cd $ORACLE_HOME/bin
    ./lsnrctl stop
    ./lsnrctl start
  7. Connect to your Oracle database in SQL*Plus.

  8. In SQL*Plus, create a database link for Ethereum. For example:

    CREATE PUBLIC DATABASE LINK EthereumLink
        CONNECT TO "dbuser" IDENTIFIED BY "dbpassword"
        USING 'Ethereum';

    Replace dbuser and dbpassword with your backend user name and password, if applicable.

  9. Try working with your Ethereum data. For example:

    SELECT * FROM blobBaseFee@EthereumLink;

    Alternatively, use a SQL passthrough query:

    SET SERVEROUTPUT ON
    
    DECLARE
      v_cursor NUMBER;
      v_rows_fetched NUMBER;
      v_col1 VARCHAR2(255);
    BEGIN
      v_cursor := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@EthereumLink;
    
      DBMS_HS_PASSTHROUGH.PARSE@EthereumLink(v_cursor, 'SELECT blobGasUsed FROM getBlockByNumber WHERE blockNumber = ''latest'' AND transactionDetailsFlag = true');
    
      -- Fetch rows from the result set
      LOOP
        v_rows_fetched := DBMS_HS_PASSTHROUGH.FETCH_ROW@EthereumLink(v_cursor);
        EXIT WHEN v_rows_fetched = 0;
        DBMS_HS_PASSTHROUGH.GET_VALUE@EthereumLink(v_cursor, 1, v_col1);
        DBMS_OUTPUT.PUT_LINE('Gas used: ' || v_col1);
      END LOOP;
    
      DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@EthereumLink(v_cursor);
    EXCEPTION
      WHEN OTHERS THEN
        DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@EthereumLink(v_cursor);
        RAISE;
    END;
    /

Notes

  • If you have problems connecting to Ethereum from Oracle, enable DG4ODBC tracing and check the trace files written to the $ORACLE_HOME/hs/trace directory. To enable DG4ODBC tracing, add the line HS_FDS_TRACE_LEVEL = DEBUG to initEthereum.ora and then start or restart the Oracle listener. If the trace directory does not exist, create it.

LibreOffice

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as LibreOffice.

  2. Configure an ODBC data source.

  3. Choose File > New > Database.

  4. Choose Connect to an existing database.

  5. Choose ODBC in the list, and then choose Next.

  6. Choose Browse, double-click your data source, and then choose Next.

  7. If your database requires a database user name, enter it in the User name box. If this user needs to supply a password choose the Password required check box.

  8. Choose Finish.

  9. Save the database when prompted.

    The database opens in a new Base window. From here you can access your data.

  10. In the left pane of the database window, choose the Tables icon to display a hierarchy of tables. Enter the database password if prompted, and then choose OK.

  11. To retrieve the data in a table, in the Tables pane, double-click a table.

  12. Choose the Queries icon to create a query.

    Use any of the methods listed in the Tasks pane to create a query.

    For example, choose Create Query in SQL View…​, and then, in the Query Design window, enter:

    SELECT gasUsed  FROM getBlockByNumber WHERE blockNumber = '0x152fdd8' AND transactionDetailsFlag = false

    Choose Edit > Run Query.

Go

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Go.

  2. Configure an ODBC data source.

  3. Install the odbc package for Go:

    go mod init test
    go get github.com/alexbrainman/odbc
  4. Create and then use Go to run this script, which retrieves some Ethereum data:

    package main
    
    import (
    	_ "github.com/alexbrainman/odbc"
    	"database/sql"
            "log"
    )
    
    func main() {
            // Replace the DSN value with the name of your ODBC data source.
            db, err := sql.Open("odbc",
                    "DSN=Ethereum")
            if err != nil {
                    log.Fatal(err)
            }
    
            var (
                    blocknumber string
                    transactiondetailsflag bool
                    transactions string
            )
    
            rows, err := db.Query("SELECT blockNumber, transactionDetailsFlag, transactions FROM getBlockByNumber WHERE blockNumber = 'latest' AND transactionDetailsFlag = true")
            if err != nil {
                    log.Fatal(err)
            }
            defer rows.Close()
            for rows.Next() {
                    err := rows.Scan(&blocknumber, &transactiondetailsflag, &transactions)
                    if err != nil {
                            log.Fatal(err)
                    }
                    log.Println(blocknumber, transactiondetailsflag, transactions)
            }
    
            err = rows.Err()
            if err != nil {
                    log.Fatal(err)
            }
    
            defer db.Close()
    }

Node.js

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Node.js.

  2. Configure an ODBC data source.

  3. Install the odbc module for Node.js:

    npm install odbc
  4. Create and then use Node.js to run this script, which retrieves some Ethereum data:

    const odbc = require('odbc');
    // Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver
    // data source.
    const connection = odbc.connect('DSN=Ethereum', (error, connection) => {
        connection.query('SELECT transactions  FROM getBlockByNumber WHERE blockNumber = \'latest\' AND transactionDetailsFlag = true', (error, result) => {
            if (error) { console.error(error) }
            console.log(result);
        });
    });
  5. This script retrieves the tables and views in your Easysoft ODBC-Ethereum Driver data source:

    const odbc = require('odbc');
    const connection = odbc.connect('DSN=Ethereum', (error, connection) => {
        connection.tables(null, null, null, null, (error, result) => {
            if (error) { return; }
            const util = require('util');
            console.log(util.inspect(result, {maxArrayLength: null, depth:null}))
        });
    });
  6. This script retrieves the names of the columns in these tables and views:

    const odbc = require('odbc');
    const connection = odbc.connect('DSN=Ethereum', (error, connection) => {
        connection.columns(null, null, null, null, (error, result) => {
            if (error) { return; }
            const util = require('util');
            console.log(util.inspect(result, {maxArrayLength: null, depth:null}))
        });
    });

Perl

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Perl.

  2. Configure an ODBC data source.

  3. Check whether your Perl distribution supports ODBC:

    perl -e 'use DBD::ODBC;'
  4. Do one of the following:

    • If you get no output, your Perl distribution supports ODBC. Skip to the next step.

    • If you get:

      Can't locate DBD/ODBC.pm

      you need to install DBD::ODBC before you can use the Easysoft ODBC-Ethereum Driver to connect to Ethereum.

  5. Create and then use Perl to run this script, which retrieves some Ethereum data:

    use strict;
    use DBI;
    # Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.
    my $dbh = DBI-> connect('dbi:ODBC:Ethereum');
    
    $dbh->{LongReadLen} = 524288;
    
    my $sql = "SELECT * FROM getBlockByNumber WHERE blockNumber = 'latest' AND transactionDetailsFlag = true";
    my $sth = $dbh->prepare($sql)
        or die "Can't prepare statement: $DBI::errstr";
    
    $sth->execute();
    
    # Fetch and display the result set values.
    my @names = @{$sth->{NAME}};
    print "@names\n";
    
    while ( my @row = $sth->fetchrow_array ) {
         print "@row\n";
    }
    
    $dbh->disconnect if ($dbh);
  6. This script retrieves the tables and views in your Easysoft ODBC-Ethereum Driver data source:

    use strict;
    use DBI;
    my $dbh = DBI-> connect('dbi:ODBC:Ethereum');
    
    my $sth = $dbh->table_info()
        or die "Can't prepare statement: $DBI::errstr";
    
    my @row;
    
    while (@row = $sth->fetchrow_array) {
        print join(", ", @row), "\n";
    }
    
    $dbh->disconnect if ($dbh);
  7. This script retrieves the names of the columns in these tables and views:

    use strict;
    use DBI;
    my $dbh = DBI-> connect('dbi:ODBC:Ethereum');
    
    my $sth = $dbh->column_info('','','','')
        or die "Can't prepare statement: $DBI::errstr";
    
    my @row;
    while (@row = $sth->fetchrow_array) {
        print join(", ", @row), "\n";
    }
    
    $dbh->disconnect if ($dbh);

Further information

PHP

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as PHP.

  2. Configure an ODBC data source.

  3. Check whether your PHP distribution supports ODBC. In php.ini, make sure there is no comment character (;) before the extension_dir and extension=odbc settings (;extension_dir=directory becomes extension_dir=directory and ;extension=odbc becomes extension=odbc).

  4. Create and then use PHP to run this script, which retrieves some Ethereum data:

    <?php
      // Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.
      //  If your database requires a user name and password, supply them in the odbc_connect_call.
      $con = odbc_connect("Ethereum", "", "");
      $stmt = odbc_exec($con, "SELECT * FROM getBlockByNumber WHERE blockNumber = 'latest' AND transactionDetailsFlag = true");
       while($row = odbc_fetch_row($stmt))
       {
          for($i=1;$i<=odbc_num_fields($stmt);$i++)
          {
              echo odbc_result($stmt, $i);
          }
       }
      odbc_close($con);
    ?>
  5. This script retrieves the tables and views in your Easysoft ODBC-Ethereum Driver data source:

    <?php
    $con = odbc_connect("Ethereum", "", "");
    $tables = odbc_tables($con);
    while (($row = odbc_fetch_array($tables))) {
        print_r($row);
    }
    odbc_close($con);
    ?>
  6. This script retrieves the names of the columns in these tables and views:

    <?php
    $con = odbc_connect("Ethereum", "", "");
    $columns = odbc_columns($con);
    while (($row = odbc_fetch_array($columns))) {
        print_r($row);
    }
    odbc_close($con);
    ?>

Further information

Python

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as Python.

  2. Configure an ODBC data source.

  3. Check whether your Python distribution supports ODBC.

    pip list

    If you don’t have pip installed:

    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    python get-pip.py
  4. Do one of the following:

    • If the output contains pyodbc, your Python distribution supports ODBC. Skip to the next step.

    • If the output does not contain pyodbc, use pip to install this module:

      pip install pyodbc
  5. Create and then use Python to run this script, which retrieves some Ethereum data:

    import pyodbc
    
    # Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.
    cnxn = pyodbc.connect("DSN=Ethereum")
    cursor = cnxn.cursor()
    sql = "SELECT * FROM getBlockByNumber WHERE blockNumber = 'latest' AND transactionDetailsFlag = true"
    cursor.execute(sql)
    rows = cursor.fetchall()
    column_names = [column[0] for column in cursor.description]
    
    print("Columns:", column_names)
    for row in rows:
        print(row)
    
    cnxn.close()
    exit()
  6. This script retrieves the tables and views in your Easysoft ODBC-Ethereum Driver data source:

    import pyodbc
    
    # Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.
    cnxn = pyodbc.connect("DSN=Ethereum")
    cursor = cnxn.cursor()
    cursor.tables()
    rows = cursor.fetchall()
    for row in rows:
         print(row.table_name)
    exit()
  7. This script retrieves the names of the columns in these tables and views:

    import pyodbc
    
    # Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.
    cnxn = pyodbc.connect("DSN=Ethereum")
    cursor = cnxn.cursor()
    cursor.columns()
    rows = cursor.fetchall()
    for row in rows:
         print(row.table_name, row.column_name)
    exit()

Further information

R

  1. Install the Easysoft ODBC-Ethereum Driver on same computer as R.

  2. Configure an ODBC data source.

  3. In R Console, check whether your R distribution supports ODBC.

    library("RODBC")
  4. Do one of the following:

    • If you get no output, you have the ODBC library for R. Skip to the next step.

    • If you get an "there is no package" error, install the ODBC library for R:

      install.packages("RODBC")
  5. Create and then use R to run this script, which retrieves some Ethereum data:

    library("RODBC")
    # Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.
    ch <- odbcConnect("Ethereum")
    sqlQuery(ch, paste("SELECT blockNumber, transactionDetailsFlag, transactions FROM getBlockByNumber WHERE blockNumber = 'latest' AND transactionDetailsFlag = true"))
    odbcClose(ch)
    quit()
  6. This script retrieves the tables and views in your Easysoft ODBC-Ethereum Driver data source:

    library("RODBC")
    # Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.
    ch <- odbcConnect("Ethereum")
    sqlTables(ch)
    odbcClose(ch)
    quit()
  7. This script retrieves the names of the columns in the specified table or view:

    library("RODBC")
    # Replace Ethereum with the name of your Easysoft ODBC-Ethereum Driver data source.
    ch <- odbcConnect("Ethereum")
    # You may need to change the capitalisation of getBlockByNumber to all upper case or all lower case.
    sqlColumns(ch, sqtable="getBlockByNumber")
    odbcClose(ch)
    quit()