Tools to facilitate adding an OData interface in front of a SQL database.
Project description
SQL To OData
This Python package provides tools to facilitate adding an OData interface in front of a SQL database. It currently only supports extracting SQLite table schemas and data in their entirety into static files, which can then be hosted on a website or otherwise provided to OData consumers.
It was initially built to create data that can be consumed on Tableau Public.
Prerequisites
Installation is via pip
:
pip install sql-to-odata
Usage
Basic usage is as follows:
import sql_to_odata
odata_interface = sql_to_odata.ODataInterface(sqlite_filename='stuff.db')
# Extracts the schema for all tables in XML format
schema_xml = odata_interface.get_database_schema_xml()
# Extracts the data from a single table in JSON format
table_json = odata_interface.get_table_json('people')
# Dumps the schemas and all tables to a folder, with the schema
# file named "$metadata" and data files named after the tables;
# this output format can be directly served on a website
odata_interface.dump_database('/path/to/output')
# Dump only a portion of the tables in the database
odata_interface.dump_database('/path/to/output', tables_to_include=['people', 'places', 'things'])
Run help(sql_to_odata)
to get more information on the available functions.
To-Do
- Translate settings for nullable fields, default values, and primary keys
- Create a test database that includes more variety of stuff, esp around datatypes
- Add tests to ensure mapping of dates and times works (esp since OData requires a TZ-aware datetime)
- Add support for more source databases
References
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
sql_to_odata-0.3.1.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for sql_to_odata-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8ae2fda8b2bd0b0fb9b3eb6ff47c010116e677e8d3c212309578ae65c0eb441 |
|
MD5 | 37c39a4627c892941e2a1ef5d2e53330 |
|
BLAKE2b-256 | 2c37b0d29ba9d8f2b593e1de002789a1b0710495c234c2c8b655c656fe81693f |