Skip to main content

SQL loader for Socrata data sets

Project description

🏛️ socrata2sql LICENSE

Plenty of state and local governments use Socrata to run their open data portals. This tool allows you to grab a dataset from one of these portals and copy it into a SQL database of your choice. It uses the Socrata API to understand the columns in the dataset and attempts to create correctly-typed columns in the SQL database to match, including PostGIS geometries if the database and source dataset support them.

Requirements

  • Python 3.x

Installation

$ pipenv install socrata2sql

or

$ pip install socrata2sql

Usage

Socrata to SQL database loader

Load a dataset from a Socrata-powered open data portal into a SQL database.
Uses the Socrata API to inspect the dataset, then sets up a table with matching
SQL types and loads all rows. The loader supports any database supported by
SQLalchemy.

Usage:
  socrata2sql insert <site> <dataset_id> [-d=<database_url>] [-a=<app_token>] [-t=<table_name>]
  socrata2sql ls <site> [-a=<app_token>]
  socrata2sql (-h | --help)
  socrata2sql (-v | --version)

Options:
  <site>             The domain for the open data site. Ex: www.dallasopendata.com
  <dataset_id>       The ID of the dataset on the open data site. This is usually
                     a few characters, separated by a hyphen, at the end of the
                     URL. Ex: 64pp-jeba
  -d=<database_url>  Database connection string for destination database as
                     dialect+driver://username:password@host:port/database.
                     Default: sqlite:///<dataset name>.sqlite
  -t=<table_name>    Destiation table in the database. Defaults to a sanitized
                     version of the dataset's name on Socrata.
  -a=<app_token>     App token for the site. Only necessary for high-volume
                     requests. Default: None
  -h --help          Show this screen.
  -v --version       Show version.

Examples:
  List all datasets on the Dallas open data portal:
  $ socrata2sql ls www.dallasopendata.com

  Load the Dallas check register into a local SQLite file (file name chosen
  from the dataset name):
  $ socrata2sql insert www.dallasopendata.com 64pp-jeba

  Load it into a PostgreSQL database call mydb:
  $ socrata2sql insert www.dallasopendata.com 64pp-jeba postgresql:///mydb

Copyright

© 2019 The Dallas Morning News

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

socrata2sql-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

socrata2sql-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file socrata2sql-0.1.1.tar.gz.

File metadata

  • Download URL: socrata2sql-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

File hashes

Hashes for socrata2sql-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b6cc1aca128380cbd8e5be3bcbfdf0d83a1e1ebbb07b005f068fca488723badd
MD5 2f44dcd8c0d99ccf27920c8c96073d28
BLAKE2b-256 ed6e90923ec87ee06d6316412bd80f9d2b4c9ecd716e6dad79d4f25f230e8cdd

See more details on using hashes here.

File details

Details for the file socrata2sql-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: socrata2sql-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

File hashes

Hashes for socrata2sql-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ef4ec68a9d5ab3d41de836d179101217a64fd3383961e697b513fc5642a9b89
MD5 2599d9680c5acfffc59f213069865e3f
BLAKE2b-256 6f616267d6cf7115d0d573b1da5e067b87580b86a05b05a6e0feaf708c634d78

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page