summaryrefslogtreecommitdiff
path: root/python-splicemachinesa.spec
blob: 0b73841a6355aa474e21935163a63bfbddcd129d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
%global _empty_manifest_terminate_build 0
Name:		python-splicemachinesa
Version:	0.4.4
Release:	1
Summary:	SQLAlchemy support for Splice Machine RDBMS
License:	Apache License 2.0
URL:		https://splicemachine.com
Source0:	https://mirrors.aliyun.com/pypi/web/packages/c8/a0/b0c49fe8f4f4bac9d0ba99e217880e36564cc430d45751485428d8f09be6/splicemachinesa-0.4.4.tar.gz
BuildArch:	noarch


%description
# Splice Machine SQLAlchemy Adapter

[![PyPI version](https://badge.fury.io/py/splicemachinesa.svg)](https://badge.fury.io/py/splicemachinesa)

## Description:
* This python package allows users to integrate new and existing 
SQLAlchemy applications with Splice Machine
* SQLAlchemy exposes a uniform API for database-backed applications,
which can be easily used with Splice Machine via this adaptor
* Supported on Splice Machine Versions >= 2.8.0.1920
* Requires Python 3.6+
## Installation:

There are two ways to install this Driver. With and without ODBC Driver custom installation. We recommend without. When running these commands, you must either use sudo or have root access.

### Without ODBC Driver Custom Installation
#### Mac
`brew install unixodbc`
`pip install splicemachinesa`
#### Linux
First ensure you have the following packages installed. They are necessary for pyodbc.<br>
Ubuntu:
* build-essential
* libssl-dev
* libffi-dev
* unixodbc
* unixodbc-dev
* python3-dev
* curl
* unzip
* iodbc

`sudo apt -y update && sudo apt -y upgrade && sudo apt -y install build-essential libssl-dev libffi-dev unixodbc unixodbc-dev python3-dev curl unzip iodbc`

Centos:
* unzip
* gcc
* openssl-devel
* gcc-c++
* unixODBC-devel
* unixODBC
* python3-devel

`sudo yum -y update && sudo yum -y install unzip gcc openssl-devel gcc-c++ unixODBC-devel unixODBC python3-devel`

Then run `pip install splicemachinesa`
<br>

**Note:** If you have an error during installation, it is likely with the installation of PyODBC. When searching the error, reference PyODBC in the search.

### With Custom ODBC Driver Installation
#### ODBC Driver:
First, download the appropriate [Splice Machine ODBC](https://doc.splicemachine.com/tutorials_connect_odbcinstall.html) driver for your system.
<hr><br>
Mac OSX 64 bit Driver: <a href="https://splice-releases.s3.amazonaws.com/odbc-driver/MacOSX64/splice_odbc_macosx64-2.8.73.0.tar.gz">Download</a><br>
Linux 64 bit Driver: <a href="https://splice-releases.s3.amazonaws.com/odbc-driver/Linux64/splice_odbc_linux64-2.8.73.0.tar.gz">Download</a><br>
<br><b>Note: Windows is not currently supported for Splice Machine SQLAlchemy ODBC</b><br>
<hr><br>
Then, follow the instructions <a href="https://doc.splicemachine.com/tutorials_connect_odbcinstall.html">here</a> to finish the installation, but use the download links above to retrieve the Driver tarball
<br><hr>

Once the Driver is installed, you can pip install splicemachinesa.

<b>NOTE: If you are on Mac, you must install unixODBC</b><br>
`brew install unixodbc`

```
pip install splicemachinesa
```

### Usage

You can use this package for SqlAlchemy usage or raw ODBC usage

#### ODBC Connection Only (Basic Auth)
```
from splicemachinesa.pyodbc import splice_connect
ODBC_CONNECTION = splice_connect(URL=[URL], UID=[UID], PWD=[PWD], SSL=[SSL])
```
Filling in `UID`, `PWD`, `URL`, and `SSL` with the proper values for your database. SSL defaults to 'basic' If you are connecting to the Splice Database _inside_ the same network (ie standalone splice) you will set `SSL=None`

#### ODBC Connection Only (JWT Connection)
```
from splicemachinesa.pyodbc import splice_connect
ODBC_CONNECTION = splice_connect(URL=[URL], JWT_TOKEN=[JWT_TOKEN], JWT_TYPE=[JWT_TYPE], SSL=[SSL])
```
Filling in `JWT_TOKEN`, `JWT_TYPE`, `URL`, and `SSL` with the proper values for your database. SSL defaults to 'basic' If you are connecting to the Splice Database _inside_ the same network (ie standalone splice) you will set `SSL=None`<br>
You must set the JWT_TYPE to use this format. Available options are ('SPLICE_JWT', 'SPLICE_JWT_PUB', 'OKTA_OAUTH', 'SPLICE_OAUTH')


#### SqlAlchemy

There are three URL formats that can be used to access 
SpliceMachine via ODBC through SQLAlchemy. The first will suffice in most cases.
<hr>

#### 1: Standard URL format<br>
Format: `splicemachinesa://[user]:[password]@[host]:[port]/[database]`<br><br>
The Driver Name defaults to `SpliceODBCDriver`, which is the default name 
when the driver is installed (specified in `odbc.ini`). However, this name can be overridden through the 
`SPLICE_ODBC_DRIVER_NAME` environment variable.

Example:
```
from sqlalchemy import create_engine
url = 'splicemachinesa://splice:admin@127.0.0.1:1527/splicedb'
engine = create_engine(url)
```

#### 2. Custom Configuration Without Driver
Format: `splicemachinesa://?DRIVER=[driver]&URL=[URL]&PORT=[PORT]&UID=[USER]&PWD=[PASSWORD]`
<br><br>You can use this SQLAlchemy driver without an ODBC configuration (meaning running the installation from Splice Machine docs)
by manually specifying the driver path.

* On OSX (given installation with `sudo` ), the Driver is found in `/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib`
* On OSX, Without `sudo` this driver is located at `$HOME/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib`
* On Linux (given ODBC Driver installation with `sudo`), this is found in `/usr/local/splice/libsplice_odbc.so`
* On Linux, Without `sudo` it is found in `$HOME/splice`.

<br>
We provide a utility function for simplifying the URL building process. <br>
This method is easier for an automated driver configuration (e.g. inside Docker) because you only need
to copy to Driver binary. <br><br>Note: Error messages will not be rendered properly with this approach.


Example Linux:
```
from sqlalchemy import create_engine
from splicemachinesa.utilities import url_builder

url = url_builder('/usr/local/splice/lib/libsplice_odbc.so', host='localhost', port=1527,
user='splice', password='admin')
 
engine = create_engine(url) 
```

Example Mac:
```
from sqlalchemy import create_engine
from splicemachinesa.utilities import url_builder

url = url_builder('/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib', host='localhost', port=1527, 
user='splice', password='admin')
 
engine = create_engine(url) 
```

#### 3. DSN Configuration
Format: `splicemachinesa://[dsn]`
Splice Machine SQLAlchemy also supports ODBC DSNs for 
Driver configuration. This means that rather than explicitly specifying
configuration options in the URL string, they are rendered from the odbc.ini file. This is also the only method that 
supports Kerberos Authentication for Splice Clusters. You can see how to use Kerberos 
<a href="https://doc.splicemachine.com/developers_fundamentals_haproxy.html">here</a>. The `odbc.ini` file is located 
at these locations depending on whether or not the installer was run as root.<br><br>
With/without `sudo` installation- Mac OSX: `$HOME/.odbc.ini`<br>
With `sudo` Linux: `/etc/odbc.ini`<br>
Without `sudo` Linux: `$HOME/.odbc.ini`. In this file, if you have a key named `USER`,
rename this to `UID`. <br><br>The default DSN is `SpliceODBC64`.

Example:
```
from sqlalchemy import create_engine
url = 'splicemachinesa://SpliceODBC64'
engine = create_engine(url)
```


#### Testing
1) First make sure you have a fresh
installation of Splice Machine
running (either Standalone or Cloud/Bespoke/On-Prem)
with an appropriate SQLAlchemy Splice Machine connection
string for accessing it

```
# register any changes for testing
cd /path/to/splice_sqlalchemy
sudo pip install .
sudo pip install pytest
pytest -vv --db-url 'splicemachinesa://[...]'
```

#### Features not yet supported
- Common Table Expressions
- Indices Reflection
- Check + Unicode Reflection
- Nullable Reflection
- ORDER BY COLLATE
- Empty Set Insertion
- Unicode String Support
- Reflector for Order by Foreign Key
- limit_offset_in_unions_from_alias

%package -n python3-splicemachinesa
Summary:	SQLAlchemy support for Splice Machine RDBMS
Provides:	python-splicemachinesa
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-splicemachinesa
# Splice Machine SQLAlchemy Adapter

[![PyPI version](https://badge.fury.io/py/splicemachinesa.svg)](https://badge.fury.io/py/splicemachinesa)

## Description:
* This python package allows users to integrate new and existing 
SQLAlchemy applications with Splice Machine
* SQLAlchemy exposes a uniform API for database-backed applications,
which can be easily used with Splice Machine via this adaptor
* Supported on Splice Machine Versions >= 2.8.0.1920
* Requires Python 3.6+
## Installation:

There are two ways to install this Driver. With and without ODBC Driver custom installation. We recommend without. When running these commands, you must either use sudo or have root access.

### Without ODBC Driver Custom Installation
#### Mac
`brew install unixodbc`
`pip install splicemachinesa`
#### Linux
First ensure you have the following packages installed. They are necessary for pyodbc.<br>
Ubuntu:
* build-essential
* libssl-dev
* libffi-dev
* unixodbc
* unixodbc-dev
* python3-dev
* curl
* unzip
* iodbc

`sudo apt -y update && sudo apt -y upgrade && sudo apt -y install build-essential libssl-dev libffi-dev unixodbc unixodbc-dev python3-dev curl unzip iodbc`

Centos:
* unzip
* gcc
* openssl-devel
* gcc-c++
* unixODBC-devel
* unixODBC
* python3-devel

`sudo yum -y update && sudo yum -y install unzip gcc openssl-devel gcc-c++ unixODBC-devel unixODBC python3-devel`

Then run `pip install splicemachinesa`
<br>

**Note:** If you have an error during installation, it is likely with the installation of PyODBC. When searching the error, reference PyODBC in the search.

### With Custom ODBC Driver Installation
#### ODBC Driver:
First, download the appropriate [Splice Machine ODBC](https://doc.splicemachine.com/tutorials_connect_odbcinstall.html) driver for your system.
<hr><br>
Mac OSX 64 bit Driver: <a href="https://splice-releases.s3.amazonaws.com/odbc-driver/MacOSX64/splice_odbc_macosx64-2.8.73.0.tar.gz">Download</a><br>
Linux 64 bit Driver: <a href="https://splice-releases.s3.amazonaws.com/odbc-driver/Linux64/splice_odbc_linux64-2.8.73.0.tar.gz">Download</a><br>
<br><b>Note: Windows is not currently supported for Splice Machine SQLAlchemy ODBC</b><br>
<hr><br>
Then, follow the instructions <a href="https://doc.splicemachine.com/tutorials_connect_odbcinstall.html">here</a> to finish the installation, but use the download links above to retrieve the Driver tarball
<br><hr>

Once the Driver is installed, you can pip install splicemachinesa.

<b>NOTE: If you are on Mac, you must install unixODBC</b><br>
`brew install unixodbc`

```
pip install splicemachinesa
```

### Usage

You can use this package for SqlAlchemy usage or raw ODBC usage

#### ODBC Connection Only (Basic Auth)
```
from splicemachinesa.pyodbc import splice_connect
ODBC_CONNECTION = splice_connect(URL=[URL], UID=[UID], PWD=[PWD], SSL=[SSL])
```
Filling in `UID`, `PWD`, `URL`, and `SSL` with the proper values for your database. SSL defaults to 'basic' If you are connecting to the Splice Database _inside_ the same network (ie standalone splice) you will set `SSL=None`

#### ODBC Connection Only (JWT Connection)
```
from splicemachinesa.pyodbc import splice_connect
ODBC_CONNECTION = splice_connect(URL=[URL], JWT_TOKEN=[JWT_TOKEN], JWT_TYPE=[JWT_TYPE], SSL=[SSL])
```
Filling in `JWT_TOKEN`, `JWT_TYPE`, `URL`, and `SSL` with the proper values for your database. SSL defaults to 'basic' If you are connecting to the Splice Database _inside_ the same network (ie standalone splice) you will set `SSL=None`<br>
You must set the JWT_TYPE to use this format. Available options are ('SPLICE_JWT', 'SPLICE_JWT_PUB', 'OKTA_OAUTH', 'SPLICE_OAUTH')


#### SqlAlchemy

There are three URL formats that can be used to access 
SpliceMachine via ODBC through SQLAlchemy. The first will suffice in most cases.
<hr>

#### 1: Standard URL format<br>
Format: `splicemachinesa://[user]:[password]@[host]:[port]/[database]`<br><br>
The Driver Name defaults to `SpliceODBCDriver`, which is the default name 
when the driver is installed (specified in `odbc.ini`). However, this name can be overridden through the 
`SPLICE_ODBC_DRIVER_NAME` environment variable.

Example:
```
from sqlalchemy import create_engine
url = 'splicemachinesa://splice:admin@127.0.0.1:1527/splicedb'
engine = create_engine(url)
```

#### 2. Custom Configuration Without Driver
Format: `splicemachinesa://?DRIVER=[driver]&URL=[URL]&PORT=[PORT]&UID=[USER]&PWD=[PASSWORD]`
<br><br>You can use this SQLAlchemy driver without an ODBC configuration (meaning running the installation from Splice Machine docs)
by manually specifying the driver path.

* On OSX (given installation with `sudo` ), the Driver is found in `/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib`
* On OSX, Without `sudo` this driver is located at `$HOME/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib`
* On Linux (given ODBC Driver installation with `sudo`), this is found in `/usr/local/splice/libsplice_odbc.so`
* On Linux, Without `sudo` it is found in `$HOME/splice`.

<br>
We provide a utility function for simplifying the URL building process. <br>
This method is easier for an automated driver configuration (e.g. inside Docker) because you only need
to copy to Driver binary. <br><br>Note: Error messages will not be rendered properly with this approach.


Example Linux:
```
from sqlalchemy import create_engine
from splicemachinesa.utilities import url_builder

url = url_builder('/usr/local/splice/lib/libsplice_odbc.so', host='localhost', port=1527,
user='splice', password='admin')
 
engine = create_engine(url) 
```

Example Mac:
```
from sqlalchemy import create_engine
from splicemachinesa.utilities import url_builder

url = url_builder('/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib', host='localhost', port=1527, 
user='splice', password='admin')
 
engine = create_engine(url) 
```

#### 3. DSN Configuration
Format: `splicemachinesa://[dsn]`
Splice Machine SQLAlchemy also supports ODBC DSNs for 
Driver configuration. This means that rather than explicitly specifying
configuration options in the URL string, they are rendered from the odbc.ini file. This is also the only method that 
supports Kerberos Authentication for Splice Clusters. You can see how to use Kerberos 
<a href="https://doc.splicemachine.com/developers_fundamentals_haproxy.html">here</a>. The `odbc.ini` file is located 
at these locations depending on whether or not the installer was run as root.<br><br>
With/without `sudo` installation- Mac OSX: `$HOME/.odbc.ini`<br>
With `sudo` Linux: `/etc/odbc.ini`<br>
Without `sudo` Linux: `$HOME/.odbc.ini`. In this file, if you have a key named `USER`,
rename this to `UID`. <br><br>The default DSN is `SpliceODBC64`.

Example:
```
from sqlalchemy import create_engine
url = 'splicemachinesa://SpliceODBC64'
engine = create_engine(url)
```


#### Testing
1) First make sure you have a fresh
installation of Splice Machine
running (either Standalone or Cloud/Bespoke/On-Prem)
with an appropriate SQLAlchemy Splice Machine connection
string for accessing it

```
# register any changes for testing
cd /path/to/splice_sqlalchemy
sudo pip install .
sudo pip install pytest
pytest -vv --db-url 'splicemachinesa://[...]'
```

#### Features not yet supported
- Common Table Expressions
- Indices Reflection
- Check + Unicode Reflection
- Nullable Reflection
- ORDER BY COLLATE
- Empty Set Insertion
- Unicode String Support
- Reflector for Order by Foreign Key
- limit_offset_in_unions_from_alias

%package help
Summary:	Development documents and examples for splicemachinesa
Provides:	python3-splicemachinesa-doc
%description help
# Splice Machine SQLAlchemy Adapter

[![PyPI version](https://badge.fury.io/py/splicemachinesa.svg)](https://badge.fury.io/py/splicemachinesa)

## Description:
* This python package allows users to integrate new and existing 
SQLAlchemy applications with Splice Machine
* SQLAlchemy exposes a uniform API for database-backed applications,
which can be easily used with Splice Machine via this adaptor
* Supported on Splice Machine Versions >= 2.8.0.1920
* Requires Python 3.6+
## Installation:

There are two ways to install this Driver. With and without ODBC Driver custom installation. We recommend without. When running these commands, you must either use sudo or have root access.

### Without ODBC Driver Custom Installation
#### Mac
`brew install unixodbc`
`pip install splicemachinesa`
#### Linux
First ensure you have the following packages installed. They are necessary for pyodbc.<br>
Ubuntu:
* build-essential
* libssl-dev
* libffi-dev
* unixodbc
* unixodbc-dev
* python3-dev
* curl
* unzip
* iodbc

`sudo apt -y update && sudo apt -y upgrade && sudo apt -y install build-essential libssl-dev libffi-dev unixodbc unixodbc-dev python3-dev curl unzip iodbc`

Centos:
* unzip
* gcc
* openssl-devel
* gcc-c++
* unixODBC-devel
* unixODBC
* python3-devel

`sudo yum -y update && sudo yum -y install unzip gcc openssl-devel gcc-c++ unixODBC-devel unixODBC python3-devel`

Then run `pip install splicemachinesa`
<br>

**Note:** If you have an error during installation, it is likely with the installation of PyODBC. When searching the error, reference PyODBC in the search.

### With Custom ODBC Driver Installation
#### ODBC Driver:
First, download the appropriate [Splice Machine ODBC](https://doc.splicemachine.com/tutorials_connect_odbcinstall.html) driver for your system.
<hr><br>
Mac OSX 64 bit Driver: <a href="https://splice-releases.s3.amazonaws.com/odbc-driver/MacOSX64/splice_odbc_macosx64-2.8.73.0.tar.gz">Download</a><br>
Linux 64 bit Driver: <a href="https://splice-releases.s3.amazonaws.com/odbc-driver/Linux64/splice_odbc_linux64-2.8.73.0.tar.gz">Download</a><br>
<br><b>Note: Windows is not currently supported for Splice Machine SQLAlchemy ODBC</b><br>
<hr><br>
Then, follow the instructions <a href="https://doc.splicemachine.com/tutorials_connect_odbcinstall.html">here</a> to finish the installation, but use the download links above to retrieve the Driver tarball
<br><hr>

Once the Driver is installed, you can pip install splicemachinesa.

<b>NOTE: If you are on Mac, you must install unixODBC</b><br>
`brew install unixodbc`

```
pip install splicemachinesa
```

### Usage

You can use this package for SqlAlchemy usage or raw ODBC usage

#### ODBC Connection Only (Basic Auth)
```
from splicemachinesa.pyodbc import splice_connect
ODBC_CONNECTION = splice_connect(URL=[URL], UID=[UID], PWD=[PWD], SSL=[SSL])
```
Filling in `UID`, `PWD`, `URL`, and `SSL` with the proper values for your database. SSL defaults to 'basic' If you are connecting to the Splice Database _inside_ the same network (ie standalone splice) you will set `SSL=None`

#### ODBC Connection Only (JWT Connection)
```
from splicemachinesa.pyodbc import splice_connect
ODBC_CONNECTION = splice_connect(URL=[URL], JWT_TOKEN=[JWT_TOKEN], JWT_TYPE=[JWT_TYPE], SSL=[SSL])
```
Filling in `JWT_TOKEN`, `JWT_TYPE`, `URL`, and `SSL` with the proper values for your database. SSL defaults to 'basic' If you are connecting to the Splice Database _inside_ the same network (ie standalone splice) you will set `SSL=None`<br>
You must set the JWT_TYPE to use this format. Available options are ('SPLICE_JWT', 'SPLICE_JWT_PUB', 'OKTA_OAUTH', 'SPLICE_OAUTH')


#### SqlAlchemy

There are three URL formats that can be used to access 
SpliceMachine via ODBC through SQLAlchemy. The first will suffice in most cases.
<hr>

#### 1: Standard URL format<br>
Format: `splicemachinesa://[user]:[password]@[host]:[port]/[database]`<br><br>
The Driver Name defaults to `SpliceODBCDriver`, which is the default name 
when the driver is installed (specified in `odbc.ini`). However, this name can be overridden through the 
`SPLICE_ODBC_DRIVER_NAME` environment variable.

Example:
```
from sqlalchemy import create_engine
url = 'splicemachinesa://splice:admin@127.0.0.1:1527/splicedb'
engine = create_engine(url)
```

#### 2. Custom Configuration Without Driver
Format: `splicemachinesa://?DRIVER=[driver]&URL=[URL]&PORT=[PORT]&UID=[USER]&PWD=[PASSWORD]`
<br><br>You can use this SQLAlchemy driver without an ODBC configuration (meaning running the installation from Splice Machine docs)
by manually specifying the driver path.

* On OSX (given installation with `sudo` ), the Driver is found in `/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib`
* On OSX, Without `sudo` this driver is located at `$HOME/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib`
* On Linux (given ODBC Driver installation with `sudo`), this is found in `/usr/local/splice/libsplice_odbc.so`
* On Linux, Without `sudo` it is found in `$HOME/splice`.

<br>
We provide a utility function for simplifying the URL building process. <br>
This method is easier for an automated driver configuration (e.g. inside Docker) because you only need
to copy to Driver binary. <br><br>Note: Error messages will not be rendered properly with this approach.


Example Linux:
```
from sqlalchemy import create_engine
from splicemachinesa.utilities import url_builder

url = url_builder('/usr/local/splice/lib/libsplice_odbc.so', host='localhost', port=1527,
user='splice', password='admin')
 
engine = create_engine(url) 
```

Example Mac:
```
from sqlalchemy import create_engine
from splicemachinesa.utilities import url_builder

url = url_builder('/Library/ODBC/SpliceMachine/libsplice_odbc64.dylib', host='localhost', port=1527, 
user='splice', password='admin')
 
engine = create_engine(url) 
```

#### 3. DSN Configuration
Format: `splicemachinesa://[dsn]`
Splice Machine SQLAlchemy also supports ODBC DSNs for 
Driver configuration. This means that rather than explicitly specifying
configuration options in the URL string, they are rendered from the odbc.ini file. This is also the only method that 
supports Kerberos Authentication for Splice Clusters. You can see how to use Kerberos 
<a href="https://doc.splicemachine.com/developers_fundamentals_haproxy.html">here</a>. The `odbc.ini` file is located 
at these locations depending on whether or not the installer was run as root.<br><br>
With/without `sudo` installation- Mac OSX: `$HOME/.odbc.ini`<br>
With `sudo` Linux: `/etc/odbc.ini`<br>
Without `sudo` Linux: `$HOME/.odbc.ini`. In this file, if you have a key named `USER`,
rename this to `UID`. <br><br>The default DSN is `SpliceODBC64`.

Example:
```
from sqlalchemy import create_engine
url = 'splicemachinesa://SpliceODBC64'
engine = create_engine(url)
```


#### Testing
1) First make sure you have a fresh
installation of Splice Machine
running (either Standalone or Cloud/Bespoke/On-Prem)
with an appropriate SQLAlchemy Splice Machine connection
string for accessing it

```
# register any changes for testing
cd /path/to/splice_sqlalchemy
sudo pip install .
sudo pip install pytest
pytest -vv --db-url 'splicemachinesa://[...]'
```

#### Features not yet supported
- Common Table Expressions
- Indices Reflection
- Check + Unicode Reflection
- Nullable Reflection
- ORDER BY COLLATE
- Empty Set Insertion
- Unicode String Support
- Reflector for Order by Foreign Key
- limit_offset_in_unions_from_alias

%prep
%autosetup -n splicemachinesa-0.4.4

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-splicemachinesa -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4.4-1
- Package Spec generated