whosonfirst / py-mapzen-whosonfirst-spatial

Python library for working with spatial databases (and services) and Who's On First documents.
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Spatialite updates #10

Open stepps00 opened 6 years ago

stepps00 commented 6 years ago

Updated the existing spatialite branch, making changes to the sqlite.py script.

I will have more changes, but this version should be less fussy and work with sqlite3.

thisisaaronland commented 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)
stepps00 commented 6 years ago

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...