Skip to content

Instantly share code, notes, and snippets.

@naren-dremio
naren-dremio / dremio_flight.py
Last active May 19, 2023 00:15
for dremio cloud
import certifi
import sys
from http.cookies import SimpleCookie
from pyarrow import flight
class DremioClientAuthMiddlewareFactory(flight.ClientMiddlewareFactory):
"""A factory that creates DremioClientAuthMiddleware(s)."""
username = "dremio"
password = "dremio123"
sqlquery = '''SELECT * FROM Business.Transportation."NYC Trips" limit 10000'''
hostname = "localhost"
flightport = 32010
from pyarrow import flight
class DremioClientAuthMiddlewareFactory(flight.ClientMiddlewareFactory):
def __init__(self):
#Install hive:
export HIVE_HOME=/opt/homebrew/Cellar/hive/apache-hive-3.1.2-bin
wget https://dlcdn.apache.org/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz
mkdir -p /opt/homebrew/Cellar/hive && tar xvf apache-hive-3.1.2-bin.tar.gz -C /opt/homebrew/Cellar/hive
#hive-site.xml
<?xml version="1.0"?>
<configuration>
<property>
'''
The following script is intended to provide examples to use Dremio's REST API.
Please refer to the documentation for more information: https://docs.dremio.com/rest-api/
Required library: requests
Python version: 3.7.2
'''
import requests, time
# https://community.openvpn.net/openvpn/wiki/OpenVPN3Linux?__cf_chl_jschl_tk__=d2179faf5fb96a597b82601e44f95ad0f2d99541-1613076924-0-AXswPc_bnMJfTp0DEHLhYOdCnX1hf5gnR1QQoWqE9Y_UZqFDIcBEbwTTk4n8SByO_c0_ViL_Lt5wTPWR61N-2AkStgI3YT2QnSAZocktkPSVi-t1E_w0JMT5m7jq1NUliLTrMH0IgbFb5KqH2gcsIrHVsBi7-VKDWhF-w5rQM5MqmeLZ3u_FSdcvn_Dzn0Ac1Cbl9MEghMDrmkTJn61kJxZMtWOxM7GAFS1Y5mjQnizZp0jk9XZ2l6b-OyF_Zcle3FglvJ8FUgetnjxGkjtUk4tAmGF7-xXd6_BYNtB0N9BnNJbswo2Y9YtybHT7QJWZgR_vQ695ErTyqXYUQmg2WtY
# Ubuntu 20.10
apt install apt-transport-https
wget https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub
apt-key add openvpn-repo-pkg-key.pub
wget -O /etc/apt/sources.list.d/openvpn3.list https://swupdate.openvpn.net/community/openvpn3/repos/openvpn3-groovy.list
apt update
apt install openvpn3
%sql
CREATE TABLE test
USING org.apache.spark.sql.jdbc
OPTIONS (
url "jdbc:dremio:direct=<host>:31010",
dbtable "postgres.public.actor",
user "",
password "",
driver "com.dremio.jdbc.Driver"
)
jdbcPort = 31010
jdbcDatabase = "DREMIO"
jdbcUsername = ""
jdbcPassword = ""
jdbcUrl = "jdbc:dremio:direct=<host>:31010"
connectionProperties = {
"user" : jdbcUsername,
"password" : jdbcPassword,
"driver" : "com.dremio.jdbc.Driver"
%scala
Class.forName("com.dremio.jdbc.Driver")
val jdbcPort = 31010
val jdbcDatabase = "DREMIO"
val user = ""
val password = ""
val tbl = "postgres.public.actor"
// Create the JDBC URL without passing in the user and password parameters.
'''
The following script is intended to provide examples to use Dremio's REST API.
Please refer to the documentation for more information: https://docs.dremio.com/rest-api/
Required library: requests
Python version: 3.7.2
'''
import requests, time
@naren-dremio
naren-dremio / Main.java
Created April 20, 2020 13:02
JDBC example for Dremio
// Requires JDK 1.8
// Run it with:
// javac Main.java && java -cp .:dremio-jdbc-driver-4.2.1-202004111451200819-0c3ecaea.jar Main
import java.sql.*;
import java.util.Properties;
public class Main {
public static void main(String[] args) {
final String DB_URL = "jdbc:dremio:direct=localhost:31010;";