Open stepps00 opened 6 years ago
@nvkelso @stepps00 the DICT.get(a, b)
in Python means "try to return the value of dict[a]
but if the a
key is missing then return b
At the library / constructor level you should be doing something dsn = kwargs.get("dsn", None)
and then ensuring that dsn
isn't None
and returning an error (or triggering an exception because it's Python...)
If you need or want to hardcode default use-specific options you should do that in the program that is invoking the library. For example, something like:
# e.g. a file called ~/stepps/pip.py
import optparse
opt_parser = optparse.OptionParser()
opt_parser.add_option('--dsn, dest='dsn', action='store_true', default='/usr/local/stepps.db', help='...')
options, args = opt_parser.parse_args()
sqlite_kwargs = { 'dsn': options.dsn }
pip = mapzen.whosonfirst.spatial.sqlite(**sqlite_kwargs)
Re: https://github.com/whosonfirst/py-mapzen-whosonfirst-spatial/pull/10#issuecomment-386761417 - that does makes sense; I need to chunk out a few more pieces to make this script fully functional.. I will add logic around the dsn =
in a commit shortly...
Updated the existing spatialite branch, making changes to the
sqlite.py
script.memory
from dsn)mod_spatialite.dylib
, rather thanlibspatialite
extensionrow = self.curs.fetch()
->row = self.curs.fetchone()
row_to_feature
I will have more changes, but this version should be less fussy and work with sqlite3.