You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use Drill with SQLAlchemy you will need to craft a connection string in the format below:
27
+
Drill's REST API can execute queries with results streamed to JSON returned over chunked HTTP for Drill >= 1.19, otherwise with results buffered and then returned in a conventional HTTP response. A SQLAlchemy URL to connect to Drill over REST looks like the following.
| use_ssl | boolean | Whether to connect to Drill using HTTPS |
44
+
| verify_ssl | boolean | Whether to verify the server's TLS certificate |
45
+
| impersonation_target\[1\]| string | Username of a Drill user to be impersonated by this connection |
46
+
47
+
[1] Requires a build of Drill that incorporates the fix for DRILL-8168.
48
+
49
+
### Trailing metadata
50
+
39
51
Query result metadata returned by the Drill REST API is stored in the `result_md` field of the DB-API Cursor object. Note that any trailing metadata, i.e. metadata which comes after result row data, will only be populated after you have iterated through all of the returned rows. If you need this trailing metadata you can make the cursor object reachable after it has been completely iterated by obtaining a reference to it beforehand, as follows.
52
+
40
53
```python
41
54
r = engine.execute('select current_timestamp')
42
55
r.cursor.result_md # access metadata, but only leading metadata
del cur # optionally delete the reference when done
47
60
```
48
61
49
-
### Changes in Drill 1.19 affecting drill+sadrill
62
+
### Drill < 1.19
50
63
51
64
In versions of Drill earlier than 1.19, all data values are serialised to JSON strings and column type metadata comes after the data itself. As a result, for these versions of Drill, the drill+sadrill dialect returns every data value as a string. To convert non-string data to its native type you need to typecast it yourself.
52
65
53
-
In Drill 1.19 the REST API began making use of numeric types in JSON for numbers and times, the latter via a UNIX time representation. As a result, the drill+sadrill dialect is able to return appropriate types for numbers and times when used with Drill >= 1.19.
66
+
### Drill >= 1.19
67
+
68
+
In Drill 1.19 the REST API began making use of numeric types in JSON for numbers and times, the latter via a UNIX time representation while column type metadata was moved ahead of the result data. Because of this, the drill+sadrill dialect is able to return appropriate types for numbers and times when used with Drill >= 1.19.
0 commit comments