forked from ContinuumIO/DBAdapter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add files from IOPro. The project currently builds for Python 3.5 on …
…Ubuntu
- Loading branch information
Showing
141 changed files
with
36,697 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dbadapter/_version.py export-subst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Editor temporary/working/backup files # | ||
######################################### | ||
.#* | ||
[#]*# | ||
*~ | ||
*$ | ||
*.bak | ||
*.diff | ||
*.org | ||
.project | ||
*.rej | ||
.settings/ | ||
.*.sw[nop] | ||
.sw[nop] | ||
*.tmp | ||
|
||
# Compiled source # | ||
################### | ||
*.a | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.py[ocd] | ||
*.so | ||
|
||
# Python files # | ||
################ | ||
# setup.py working directory | ||
build | ||
# sphinx build directory | ||
_build | ||
# setup.py dist directory | ||
dist | ||
doc/build | ||
doc/cdoc/build | ||
# Egg metadata | ||
*.egg-info | ||
# The shelf plugin uses this dir | ||
./.shelf | ||
|
||
# Patches # | ||
########### | ||
*.patch | ||
*.diff | ||
|
||
# OS generated files # | ||
###################### | ||
.DS_Store* | ||
.VolumeIcon.icns | ||
.fseventsd | ||
Icon? | ||
.gdb_history | ||
ehthumbs.db | ||
Thumbs.db | ||
|
||
# IPython generated files # | ||
########################### | ||
.ipynb_checkpoints | ||
|
||
# Specific cython generated c files | ||
###################### | ||
|
||
# Generated data files for /tests and /examples | ||
dbadapter/tests/data/fixedwidths | ||
dbadapter/tests/data/floats | ||
dbadapter/tests/data/ints | ||
dbadapter/tests/data/ints.gz | ||
dbadapter/tests/data/missingvalues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,66 @@ | ||
# DBAdapter | ||
Database adapters forked from IOPro | ||
|
||
DBAdapter is a Python module containing optimized data adapters for importing | ||
data from a variety of database sources into NumPy arrays and Pandas DataFrame. | ||
Database adapter leverages an optimized pyodbc module for accessing any | ||
relational database that supports the ODBC interface (SQL Server, PostgreSQL, | ||
MySQL, etc). | ||
|
||
Build Requirements | ||
------------------ | ||
|
||
Building DBAdapter requires a number of dependencies. In addition to a C/C++ dev | ||
environment, the following modules are needed, which can be installed via conda: | ||
|
||
* NumPy | ||
* Pandas | ||
* unixodbc 2.3.4 (C lib, Linux only) | ||
|
||
Building Conda Package | ||
---------------------- | ||
|
||
Note: If building under Windows, make sure the following commands are issued | ||
within the Visual Studio command prompt for version of Visual Studio that | ||
matches the version of Python you're building for. Python 2.6 and 2.7 needs | ||
Visual Studio 2008, Python 3.3 and 3.4 needs Visual Studio 2010, and Python | ||
3.5 needs Visual Studio 2015. | ||
|
||
1. Build DBAdapter using the following command: | ||
`conda build buildscripts/condarecipe --python 3.5` | ||
|
||
1. DBAdapter can now be installed from the built conda package: | ||
`conda install dbadapter --use-local` | ||
|
||
Building By Hand | ||
---------------- | ||
|
||
Note: If building under Windows, make sure the following commands are issued | ||
within the Visual Studio command prompt for version of Visual Studio that | ||
matches the version of Python you're building for. Python 2.6 and 2.7 needs | ||
Visual Studio 2008, Python 3.3 and 3.4 needs Visual Studio 2010, and Python | ||
3.5 needs Visual Studio 2015. | ||
|
||
For building DBAdapter for local development/testing: | ||
|
||
1. Install most of the above dependencies into environment called 'dbadapter': | ||
`conda env create -f environment.yml` | ||
|
||
Be sure to activate new dbadapter environment before proceeding. | ||
|
||
1. Build DBAdapter using Cython/distutils: | ||
`python setup.py build_ext --inplace` | ||
|
||
Testing | ||
------- | ||
|
||
Tests can be run by calling the dbadapter module's test function. By default | ||
only the TextAdapter tests will be run: | ||
|
||
TODO: There are no tests for pyodbc (yet). | ||
```python | ||
python -Wignore -c 'import dbadapter; dbadapter.test()' | ||
``` | ||
|
||
(Note: `numpy.testing` might produce a FurtureWarning that is not directly | ||
relevant to these unit tests). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
copy %LIBRARY_LIB%\boost_thread-vc90-mt-1_60.lib %LIBRARY_LIB%\libboost_thread-vc90-mt-1_60.lib | ||
%PYTHON% setup.py install | ||
if errorlevel 1 exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
## Use unixodbc for building pyodbc on OS X systems | ||
## without iodbc installed | ||
#export UNIXODBC_PATH=/Users/jayvius/unixODBC-2.3.4/ | ||
|
||
$PYTHON setup.py install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package: | ||
name: dbadapter | ||
version: "2.0.0" | ||
|
||
source: | ||
path: ../../ | ||
|
||
build: | ||
number: 0 | ||
|
||
requirements: | ||
build: | ||
- python | ||
- numpy | ||
- cython | ||
- unixodbc >=2.2.14 [linux] | ||
- postgresql 9.1.4 | ||
|
||
run: | ||
- python | ||
- numpy | ||
- pandas | ||
- six | ||
- ordereddict [py26] | ||
- unixodbc >=2.2.14 [linux] | ||
- postgresql 9.1.4 | ||
- psqlodbc >=09.01.0100 | ||
- sqlite >=0.96 | ||
|
||
# According to the pyodbc/INSTALL.rst document | ||
#- mysql-connector-python >=5.1.10 | ||
|
||
test: | ||
requires: | ||
- nose | ||
- pytest | ||
|
||
imports: | ||
- dbadapter | ||
- dbadapter.pyodbc | ||
|
||
about: | ||
home: http://www.continuum.io/ | ||
license: proprietary - Continuum Analytics, Inc. | ||
license_family: Proprietary | ||
summary: python interface for databases, NoSQL stores, Amazon S3, and large data files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import dbadapter | ||
|
||
print('TODO: write some tests asserting that DBAdapter functions properly') | ||
#assert dbadapter.test() | ||
|
||
print('dbadapter.__version__: %s' % dbadapter.__version__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
|
||
IOPRO_INCLUDE_PATH=$HOME/anaconda/envs/iopro-test-np1.7/include/python2.7 | ||
|
||
WHERE="$HOME/dependencies/" | ||
|
||
function mk_depend_path() | ||
{ | ||
echo $WHERE$1 | ||
} | ||
|
||
if [ ! -d $(mk_depend_path '') ]; then | ||
mkdir $(mk_depend_path '') | ||
fi | ||
|
||
pushd $(mk_depend_path '') >/dev/null | ||
|
||
|
||
# get a unixODBC driver manager | ||
if [ ! -d unixODBC-2.3.1 ]; then | ||
if [ ! -f unixODBC-2.3.1.tar.gz ]; then | ||
wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz | ||
fi | ||
|
||
tar -zxvf unixODBC-2.3.1.tar.gz | ||
pushd unixODBC-2.3.1 >/dev/null | ||
./configure | ||
make | ||
popd >/dev/null | ||
fi | ||
|
||
if [ -f unixODBC-2.3.1.tar.gz ]; then | ||
# leave it clean | ||
rm unixODBC-2.3.1.tar.gz | ||
fi | ||
|
||
|
||
IOPRO_INCLUDE_PATH=$(mk_depend_path unixODBC-2.3.1):$IOPRO_INCLUDE_PATH | ||
IOPRO_INCLUDE_PATH=$(mk_depend_path unixODBC-2.3.1/include):$IOPRO_INCLUDE_PATH | ||
export IOPRO_INCLUDE_PATH | ||
|
||
echo 'IOPRO_INCLUDE_PATH=' $IOPRO_INCLUDE_PATH | ||
|
||
IOPRO_LIBRARY_PATH=$(mk_depend_path unixODBC-2.3.1):$IOPRO_LIBRARY_PATH | ||
export IOPRO_LIBRARY_PATH | ||
|
||
echo 'IOPRO_LIBRARY_PATH=' $IOPRO_LIBRARY_PATH | ||
|
||
LD_LIBRARY_PATH=$(mk_depend_path unixODBC-2.3.1/DriverManager/.libs):$LD_LIBRARY_PATH | ||
export LD_LIBRARY_PATH | ||
|
||
echo 'LD_LIBRARY_PATH=' $LD_LIBRARY_PATH | ||
|
||
popd >/dev/null | ||
|
||
printf '\n\nBuilding...\n' | ||
python setup.py build_ext --inplace --include-dirs=$IOPRO_INCLUDE_PATH --library-dirs=$IOPRO_LIBRARY_PATH || exit 1 | ||
|
||
exit | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
PYTHON_VERSION=2.7 | ||
|
||
if [ "${PYTHON_VERSION}" == "" ]; then | ||
echo You must select a Python version with the PYTHON_VERSION variable. | ||
exit 1 | ||
fi | ||
|
||
# Start from scratch | ||
if [ -d build ]; then | ||
rm -rf build | ||
fi | ||
mkdir build | ||
cd build | ||
|
||
# Use conda to create a conda environment of the required | ||
# python version and containing the dependencies. | ||
export PYENV_PREFIX=${WORKSPACE}/build/pyenv | ||
rm -rf ${PYENV_PREFIX} | ||
~/anaconda/bin/conda create --yes -p ${PYENV_PREFIX} anaconda python=${PYTHON_VERSION} numpy=1.7 || exit 1 | ||
export PATH=${PYENV_PREFIX}/bin:${PATH} | ||
|
||
# JNB: Get rid of any iopro that conda may have installed | ||
rm -rf ${PYENV_PREFIX}/lib/python2.7/site-packages/iopro* | ||
|
||
|
||
# Get and build unix odbc lib | ||
if [ ! -f ${WORKSPACE}/unixODBC-2.3.1.tar.gz ]; then | ||
cd .. | ||
wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz | ||
cd build | ||
fi | ||
|
||
tar -zxvf ../unixODBC-2.3.1.tar.gz | ||
cd unixODBC-2.3.1 | ||
./configure | ||
make | ||
cd .. | ||
|
||
# Set up include and lib paths since we're not installing in default system paths | ||
export IOPRO_INCLUDE_PATH=${WORKSPACE}/build/unixODBC-2.3.1:${WORKSPACE}/build/unixODBC-2.3.1/include:$IOPRO_INCLUDE_PATH | ||
export IOPRO_LIBRARY_PATH=${WORKSPACE}/build/unixODBC-2.3.1/DriverManager/.libs:$IOPRO_LIBRARY_PATH | ||
export IOPRO_INCLUDE_PATH=~/anaconda/include/python${PYTHON_VERSION}:$IOPRO_INCLUDE_PATH | ||
export IOPRO_LIBRARY_PATH=~/anaconda/lib:$IOPRO_LIBRARY_PATH | ||
|
||
export LD_LIBRARY_PATH=${WORKSPACE}/build/unixODBC-2.3.1/DriverManager/.libs:$LD_LIBRARY_PATH | ||
|
||
cd .. | ||
python setup.py build_ext --inplace --include-dirs=$IOPRO_INCLUDE_PATH --library-dirs=$IOPRO_LIBRARY_PATH || exit 1 | ||
python -c 'import iopro; import sys; sys.exit(1 - iopro.test(num_records=1000))' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
DBAdapter | ||
~~~~~ | ||
DBAdapter provides tools to interface SQL databases in a fast, memory-efficient way. | ||
""" | ||
from __future__ import absolute_import | ||
|
||
from dbadapter._version import get_versions | ||
__version__ = get_versions()['version'] | ||
del get_versions | ||
|
||
from dbadapter.lib.errors import (AdapterException, AdapterIndexError, | ||
ArgumentError, ConfigurationError, | ||
DataIndexError, DataTypeError, | ||
InternalInconsistencyError, NoSuchFieldError, | ||
ParserError, SourceError, SourceNotFoundError) | ||
|
||
|
||
def test(verbosity=1, num_records=100000, results=[]): | ||
#from textadapter.tests.test_DBAdapter import run as run_dbadapter_tests | ||
#result_text = run_dbadapter_tests(verbosity=verbosity, | ||
# num_records=num_records) | ||
#results.append(result_text) | ||
|
||
#from textadapter.tests.test_io import run as run_io_tests | ||
#result_text = run_io_tests(verbosity=verbosity) | ||
#results.append(result_text) | ||
|
||
for result in results: | ||
if not result.wasSuccessful(): | ||
return False | ||
return True | ||
|
||
# pyodbc module import triggers license message | ||
import dbadapter.pyodbc |
Oops, something went wrong.