Skip to content

Commit

Permalink
add detach method to DB
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed Jan 8, 2015
1 parent faf5b87 commit 0fd0ed4
Show file tree
Hide file tree
Showing 9 changed files with 80,037 additions and 79,986 deletions.
11 changes: 11 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[bumpversion]
current_version = 3.1.3
commit = False
tag = True

[bumpversion:file:setup.py]

[bumpversion:file:doc/conf.py]
search = 'larch': '{current_version}'
replace = 'larch': '{new_version}'

10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ If you don't know what the difference is, you probably want to start with linear
This project is very much under development. There are plenty of undocumented functions
and features; use them at your own risk. Undocumented features may be non-functional,
not rigorously tested, deprecated or removed without notice in a future version. If a
function or method is `documented <http://larch.readthedocs.org>`, it is intended to be
function or method is `documented <http://larch.readthedocs.org>`_, it is intended to be
stable in future updates.

FAQ
---

*Why is the Windows download so much larger than the Mac download?*

The Windows wheel include the openblas library for linear algebra computations. The
Mac version does not need an extra library because Mac OS X includes vector math libraries
by default.
16 changes: 11 additions & 5 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@

import sys, os

larch_versions = {'larch': '3.10a-DEC2014-0-ga2c83bd', 'pandas': '0.14.1', 'apsw': '3.8.7.3-r1', 'python': '3.4.0 final', 'scipy': '0.14.0c1', 'sqlite': '3.8.7.4', 'numpy': '1.8.1'}
larch_build = '3.10a-DEC2014-0-ga2c83bd (Monday, 29 Dec 2014 05:22:27 PM CST)'
larch_versions = {
'larch': '3.1.2',
'pandas': '0.14.1',
'apsw': '3.8.7.3-r1',
'python': '3.4.0 final',
'scipy': '0.14.0c1',
'sqlite': '3.8.7.4',
'numpy': '1.8.1'
}


# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -65,8 +72,7 @@
#
# The short X.Y version.
version = larch_versions['larch'].split('-')[0]
# The full version, including alpha/beta/rc tags.
release = larch_build
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -135,7 +141,7 @@ class Mock(MagicMock):
def __getattr__(cls, name):
return Mock()

MOCK_MODULES = ['argparse', 'numpy', 'pandas', 'larch']
MOCK_MODULES = ['argparse', 'numpy', 'pandas', 'larch.core']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)


Expand Down
14 changes: 11 additions & 3 deletions doc/data.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. currentmodule:: larch

=============
Data in Larch
=============
====
Data
====

The default storage of data within Larch is handled using SQLite. This portable and
open source database system provides a common file format that is flexible and
Expand Down Expand Up @@ -116,3 +116,11 @@ other programs, or through :mod:`apsw` (included as part of Larch)
or :mod:`sqlite3` (included in standard Python distributions).



Convenience Methods
-------------------

.. automethod:: DB.attach

.. automethod:: DB.detach

4 changes: 4 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ Did this software used to be called *ELM*? Why the name change?
Python software to use names from Monty Python, particularly when you want to be able to identify
your software `from quite a long way away <https://www.youtube.com/watch?v=ug8nHaelWtc>`_.

Why is the Windows wheel download so much larger than the Mac one?

The Windows wheel include the openblas library for linear algebra computations. The
Mac version does not need an extra library because Mac OS X includes vector math libraries
by default in the Accelerate framework.


3,632 changes: 1,816 additions & 1,816 deletions py/core.py

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions py/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,12 +1113,26 @@ def database_list(self,**kwargs):
raise TypeError("type not valid")

def attach(self, sqlname, filename):
'''Attach another SQLite database.
:param sqlname: The name SQLite will use to reference the other database.
:param filename: The filename or URI to attach.
'''
if sqlname in self.values('PRAGMA database_list;', column_number=1):
return
if filename in self.values('PRAGMA database_list;', column_number=2):
return
self.execute("ATTACH '{}' AS {};".format(filename,sqlname))

def detach(self, sqlname):
'''Detach another SQLite database.
:param sqlname: The name SQLite uses to reference the other database.
'''
if sqlname not in self.values('PRAGMA database_list;', column_number=1):
return
self.execute("DETACH {};".format(sqlname))

def table_names(self, dbname="main", views=True):
qry = "SELECT name FROM "
if dbname.lower()=='temp' or dbname.lower()=='temporary':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def read(*filenames, **kwargs):
buf.append(f.read())
return sep.join(buf)

long_description = read('README.md')
long_description = read('README.rst')


setup(name='larch',
Expand Down

0 comments on commit 0fd0ed4

Please sign in to comment.