Markenson / csv-metabase-driver

A CSV metabase driver
192 stars 17 forks source link

Load CSV from HTTP Request #5

Closed tonybolzan closed 3 years ago

tonybolzan commented 4 years ago

With csvjdbc I can load a CSV from HTTP request using a custom class. But I really don't understand closure to open a PR.

https://github.com/simoc/csvjdbc/blob/master/docs/doc.md

Java example

import java.io.*;
import java.sql.*;
import java.util.*;

import org.relique.io.TableReader;

public class MyHTTPReader implements TableReader
{
  public Reader getReader(Statement statement, String tableName) throws SQLException
  {
    try
    {
      URL url = new URL("http://csvjdbc.sourceforge.net/" + tableName + ".csv");
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      InputStreamReader reader = new InputStreamReader(connection.getInputStream());
      return reader;
    }
    catch (Exception e)
    {
      throw new SQLException(e.getMessage());
    }
  }
  public List getTableNames(Connection connection)
  {
    // Return list of available table names
    Vector v = new Vector();
    v.add("sample");
    return v;
  }
}

import java.sql.*;
import org.relique.jdbc.csv.CsvDriver;

public class DemoDriver6
{
  public static void main(String []args)
  {
    try
    {
      Class.forName("org.relique.jdbc.csv.CsvDriver");
      // Give name of Java class that provides database tables.
      Connection conn = DriverManager.getConnection("jdbc:relique:csv:class:" +
        MyHTTPReader.class.getName());
      Statement stmt = conn.createStatement();
      String sql = "SELECT * FROM sample";
      ResultSet results = stmt.executeQuery(sql);
      CsvDriver.writeToCsv(results, System.out, true);
      conn.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
}
Markenson commented 3 years ago

I'll try to do this...

ernoaapa commented 3 years ago

Any updates on this? Would be awesome. I'm looking into using this driver to connect Metabase to Google Sheet by downloading the Sheet data in CSV format.

Markenson commented 3 years ago

Hi @ernoaapa! Not yet. Sorry.

I'm trying to find some time to work on this project, but is difficult.

Markenson commented 3 years ago

Hi @ernoaapa and @tonybolzan

I think release 1.1.0 solve this issue.

My regards.

janbaykara commented 3 years ago

Hi there, I'm trying to load a CSV version of a Google Sheet but this system seems to expect a directory with CSV files inside it. Is there any chance of accepting a single CSV file at a specified URL?

Markenson commented 3 years ago

Hi @janbaykara !

Download from a simple specified URL, this drive works. Check these instrucions..

I think Google Sheet has a other problem to solve because you doesn't have a specific direct URL to CSV file (or it exists?).

janbaykara commented 3 years ago

Hey @Markenson, thanks a lot for the quick response.

You are able to publish Google Sheets to a CSV URL:

Screenshot 2021-02-19 at 11 08 57

Here is an example: https://docs.google.com/spreadsheets/d/e/2PACX-1vRBNpdHH8l7yHtTchAQahKOWA6FaUQ0RT8JaHxpsqN2xiQyyG-tpfwzByVDtTV11ZZ8XwCTevM3JRlE/pub?gid=0&single=true&output=csv

I can't figure out how to ingest this URL with this plugin.

binshe commented 3 years ago

Hi @Markenson ,

Also having the issue with Google Sheets like @janbaykara described. Tried to clone the project to build it myself using 'lein install', but failed with errors below:

Could not find artifact br.com.markenson:csvjdbc:jar:1.1.1-metabase-SNAPSHOT in clojars (https://repo.clojars.org/) Could not find artifact br.com.markenson:csvjdbc:jar:1.1.1-metabase-SNAPSHOT in sonartype snapshots (https://oss.sonatype.org/content/repositories/snapshots)

Would be great to have a general url to download csv instead of combining 'customBaseUrl' and 'advanced' .

Thanks in advance!

Markenson commented 3 years ago

Hi @binshe ,

i'll try to check how to do this.

Regards

2Ben commented 3 years ago

Hi guys, I have the same issue, I cannot build the driver because of it.

Thanks! Alban

Hi @Markenson ,

Also having the issue with Google Sheets like @janbaykara described. Tried to clone the project to build it myself using 'lein install', but failed with errors below:

Could not find artifact br.com.markenson:csvjdbc:jar:1.1.1-metabase-SNAPSHOT in clojars (https://repo.clojars.org/) Could not find artifact br.com.markenson:csvjdbc:jar:1.1.1-metabase-SNAPSHOT in sonartype snapshots (https://oss.sonatype.org/content/repositories/snapshots)

Would be great to have a general url to download csv instead of combining 'customBaseUrl' and 'advanced' .

Thanks in advance!

mailsonsantos commented 3 years ago

Hello,

I have the same issue, I cannot build the driver because of it.

Thanks!

Hi @Markenson ,

Also having the issue with Google Sheets like @janbaykara described. Tried to clone the project to build it myself using 'lein install', but failed with errors below:

Could not find artifact br.com.markenson:csvjdbc:jar:1.1.1-metabase-SNAPSHOT in clojars (https://repo.clojars.org/) Could not find artifact br.com.markenson:csvjdbc:jar:1.1.1-metabase-SNAPSHOT in sonartype snapshots (https://oss.sonatype.org/content/repositories/snapshots)

Would be great to have a general url to download csv instead of combining 'customBaseUrl' and 'advanced' .

Thanks in advance!