Hi Francis,
The code below worked for me. Also, I don’t know if it matters, but did you
mean to create two cursors?
— C
import jaydebeapi
import pandas as pd
#Create the connection object
conn = jaydebeapi.connect("org.apache.drill.jdbc.Driver",
"jdbc:drill:drillbit=localhost:31010",
["admin", "password"],
"/usr/local/share/drill/jars/jdbc-driver/drill-jdbc-all-1.12.0.jar",)
#Create the Cursor Object
curs = conn.cursor()
#Execute the query
curs.execute("SELECT * FROM cp.`employee.json` LIMIT 20")
#Get the results
curs.fetchall()
#Read query results into a Pandas DataFrame
df = pd.read_sql("SELECT * FROM cp.`employee.json` LIMIT 20", conn)
> On Mar 18, 2018, at 23:41, Francis McGregor-Macdonald <[email protected]>
> wrote:
>
> Hi all,
>
> I am attempting to send a query from python3 via JayDeBeApi and am
> encountering the issue that the SQL is enclosed in a SELECT * FROM $myquery
> LIMIT 0
>
> With:
> conn = jaydebeapi.connect("org.apache.drill.jdbc.Driver",
> "jdbc:drill:drillbit=$mycluster:$myport",
> ["$username", "$password"],
> "/tmp/drill-jdbc-all-1.12.0.jar")
> curs = conn.cursor()
> curs = conn.cursor()
> curs.execute('SHOW DATABASES')
>
> ... the query hits Drill as:
> SELECT * FROM (SHOW DATABASES) LIMIT 0
>
> A select * from mytable limit 100 also has the same issue.
>
> Drill is version 1.12
>
> This also occurs with other queries. I found
> https://issues.apache.org/jira/browse/DRILL-5136 which looks similar and
> lists "Client - ODBC" (not JDBC)
>
> Has anyone else encountered this?