-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from shinichi-takii/feature/first_release
First Release
- Loading branch information
Showing
18 changed files
with
1,164 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Changes | ||
- fix # : summary... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
language: python | ||
|
||
python: | ||
- "3.4" | ||
- "3.5" | ||
- "3.6" | ||
|
||
# command to install dependencies | ||
install: | ||
- pip install -r requirements.txt | ||
- pip install -r test-requirements.txt | ||
|
||
# command to run tests | ||
script: | ||
- pytest | ||
|
||
after_success: | ||
- coveralls | ||
- codecov | ||
- codeclimate-test-reporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changelog | ||
|
||
## 1.0.0 | ||
First released |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include README.md | ||
include requirements.txt | ||
include test-requirements.txt | ||
include setup.cfg | ||
include tox.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,111 @@ | ||
# ddlparse | ||
DDL parase and Convert to BigQuery JSON schema | ||
# DDL Parse | ||
|
||
[![PyPI version](https://img.shields.io/pypi/v/ddlparse.svg)](https://pypi.python.org/pypi/ddlparse) | ||
[![Python version](https://img.shields.io/pypi/pyversions/ddlparse.svg)](https://pypi.python.org/pypi/ddlparse) | ||
[![Travis CI Build Status](https://travis-ci.org/shinichi-takii/ddlparse.svg?branch=master)](https://travis-ci.org/shinichi-takii/ddlparse) | ||
[![Coveralls Coverage Status](https://coveralls.io/repos/github/shinichi-takii/ddlparse/badge.svg?branch=master)](https://coveralls.io/github/shinichi-takii/ddlparse?branch=master) | ||
[![codecov Coverage Status](https://codecov.io/gh/shinichi-takii/ddlparse/branch/master/graph/badge.svg)](https://codecov.io/gh/shinichi-takii/ddlparse) | ||
[![Requirements Status](https://requires.io/github/shinichi-takii/ddlparse/requirements.svg?branch=master)](https://requires.io/github/shinichi-takii/ddlparse/requirements/?branch=master) | ||
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/shinichi-takii/ddlparse/blob/master/LICENSE) | ||
|
||
*DDL parase and Convert to BigQuery JSON schema module, available in Python.* | ||
|
||
---- | ||
|
||
## Features | ||
|
||
- DDL parse and get table schema information. | ||
- Currently, only the `CREATE TABLE` statement is supported. | ||
- Supported databases are MySQL, PostgreSQL, Oracle, Redshift. | ||
- Convert to [BigQuery JSON schema](https://cloud.google.com/bigquery/docs/schemas#creating_a_json_schema_file). | ||
|
||
## Requirement | ||
|
||
1. Python >= 3.4 | ||
1. [pyparsing](http://pyparsing.wikispaces.com/) | ||
|
||
## Installation | ||
|
||
### Install | ||
|
||
pip install: | ||
```bash | ||
$ pip install ddlparse | ||
``` | ||
|
||
command install: | ||
```bash | ||
$ python setup.py install | ||
``` | ||
|
||
### Update | ||
|
||
pip update: | ||
```bash | ||
$ pip install ddlparse --upgrade | ||
``` | ||
|
||
## Usage | ||
|
||
### Example | ||
|
||
```python | ||
from ddlparse import DdlParse | ||
|
||
sample_ddl = """ | ||
CREATE TABLE My_Schema.Sample_Table ( | ||
ID integer PRIMARY KEY, | ||
NAME varchar(100) NOT NULL, | ||
TOTAL bigint NOT NULL, | ||
AVG decimal(5,1) NOT NULL, | ||
CREATED_AT timestamp, | ||
UNIQUE (NAME) | ||
); | ||
""" | ||
|
||
table = DdlParse().parse(sample_ddl) | ||
|
||
print("* TABLE *") | ||
print("schema = {} : name = {} : is_temp = {}".format(table.schema, table.name, table.is_temp)) | ||
|
||
print("* BigQuery Fields *") | ||
print(table.to_bigquery_fields()) | ||
|
||
print("* BigQuery Fields - column name to lower *") | ||
print(table.to_bigquery_fields(DdlParse.NAME_CASE.lower)) | ||
|
||
print("* COLUMN *") | ||
for col in table.columns.values(): | ||
print("name = {} : data_type = {} : length = {} : precision(=length) = {} : scale = {} : constraint = {} : not_null = {} : PK = {} : unique = {} : BQ {}".format( | ||
col.name, | ||
col.data_type, | ||
col.length, | ||
col.precision, | ||
col.scale, | ||
col.constraint, | ||
col.not_null, | ||
col.primary_key, | ||
col.unique, | ||
col.to_bigquery_field() | ||
)) | ||
|
||
print("* Get Column object *") | ||
print(table.columns["Name"]) | ||
``` | ||
|
||
## License | ||
|
||
[BSD 3-Clause License](LICENSE) | ||
|
||
## Author | ||
|
||
Shinichi Takii <shinichi.takii@gmail.com> | ||
|
||
## Links | ||
|
||
- Repository : https://github.com/shinichi-takii/ddlparse | ||
- PyPI Package : https://pypi.python.org/pypi/ddlparse | ||
|
||
## Special Thanks | ||
|
||
- pyparsing : http://pyparsing.wikispaces.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
DDL Parse | ||
========= | ||
|
||
|PyPI version| |Python version| |Travis CI Build Status| |Coveralls | ||
Coverage Status| |codecov Coverage Status| |Requirements Status| | ||
|License| | ||
|
||
*DDL parase and Convert to BigQuery JSON schema module, available in | ||
Python.* | ||
|
||
-------------- | ||
|
||
Features | ||
-------- | ||
|
||
- DDL parse and get table schema information. | ||
- Currently, only the ``CREATE TABLE`` statement is supported. | ||
- Supported databases are MySQL, PostgreSQL, Oracle, Redshift. | ||
- Convert to `BigQuery JSON | ||
schema <https://cloud.google.com/bigquery/docs/schemas#creating_a_json_schema_file>`__. | ||
|
||
Requirement | ||
----------- | ||
|
||
1. Python >= 3.4 | ||
2. `pyparsing <http://pyparsing.wikispaces.com/>`__ | ||
|
||
Installation | ||
------------ | ||
|
||
Install | ||
~~~~~~~ | ||
|
||
pip install: | ||
|
||
.. code:: bash | ||
$ pip install ddlparse | ||
command install: | ||
|
||
.. code:: bash | ||
$ python setup.py install | ||
Update | ||
~~~~~~ | ||
|
||
pip update: | ||
|
||
.. code:: bash | ||
$ pip install ddlparse --upgrade | ||
Usage | ||
----- | ||
|
||
Example | ||
~~~~~~~ | ||
|
||
.. code:: python | ||
from ddlparse import DdlParse | ||
sample_ddl = """ | ||
CREATE TABLE My_Schema.Sample_Table ( | ||
ID integer PRIMARY KEY, | ||
NAME varchar(100) NOT NULL, | ||
TOTAL bigint NOT NULL, | ||
AVG decimal(5,1) NOT NULL, | ||
CREATED_AT timestamp, | ||
UNIQUE (NAME) | ||
); | ||
""" | ||
table = DdlParse().parse(sample_ddl) | ||
print("* TABLE *") | ||
print("schema = {} : name = {} : is_temp = {}".format(table.schema, table.name, table.is_temp)) | ||
print("* BigQuery Fields *") | ||
print(table.to_bigquery_fields()) | ||
print("* BigQuery Fields - column name to lower *") | ||
print(table.to_bigquery_fields(DdlParse.NAME_CASE.lower)) | ||
print("* COLUMN *") | ||
for col in table.columns.values(): | ||
print("name = {} : data_type = {} : length = {} : precision(=length) = {} : scale = {} : constraint = {} : not_null = {} : PK = {} : unique = {} : BQ {}".format( | ||
col.name, | ||
col.data_type, | ||
col.length, | ||
col.precision, | ||
col.scale, | ||
col.constraint, | ||
col.not_null, | ||
col.primary_key, | ||
col.unique, | ||
col.to_bigquery_field() | ||
)) | ||
print("* Get Column object *") | ||
print(table.columns["Name"]) | ||
License | ||
------- | ||
|
||
`BSD 3-Clause License <LICENSE>`__ | ||
|
||
Author | ||
------ | ||
|
||
Shinichi Takii shinichi.takii@gmail.com | ||
|
||
Links | ||
----- | ||
|
||
- Repository : https://github.com/shinichi-takii/ddlparse | ||
- PyPI Package : https://pypi.python.org/pypi/ddlparse | ||
|
||
Special Thanks | ||
-------------- | ||
|
||
- pyparsing : http://pyparsing.wikispaces.com/ | ||
|
||
.. |PyPI version| image:: https://img.shields.io/pypi/v/ddlparse.svg | ||
:target: https://pypi.python.org/pypi/ddlparse | ||
.. |Python version| image:: https://img.shields.io/pypi/pyversions/ddlparse.svg | ||
:target: https://pypi.python.org/pypi/ddlparse | ||
.. |Travis CI Build Status| image:: https://travis-ci.org/shinichi-takii/ddlparse.svg?branch=master | ||
:target: https://travis-ci.org/shinichi-takii/ddlparse | ||
.. |Coveralls Coverage Status| image:: https://coveralls.io/repos/github/shinichi-takii/ddlparse/badge.svg?branch=master | ||
:target: https://coveralls.io/github/shinichi-takii/ddlparse?branch=master | ||
.. |codecov Coverage Status| image:: https://codecov.io/gh/shinichi-takii/ddlparse/branch/master/graph/badge.svg | ||
:target: https://codecov.io/gh/shinichi-takii/ddlparse | ||
.. |Requirements Status| image:: https://requires.io/github/shinichi-takii/ddlparse/requirements.svg?branch=master | ||
:target: https://requires.io/github/shinichi-takii/ddlparse/requirements/?branch=master | ||
.. |License| image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg | ||
:target: https://github.com/shinichi-takii/ddlparse/blob/master/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2018 Shinichi Takii, shinichi.takii@gmail.com | ||
# | ||
# This module is part of python-ddlparse and is released under | ||
# the BSD License: https://opensource.org/licenses/BSD-3-Clause | ||
|
||
from .ddlparse import * | ||
|
||
__copyright__ = 'Copyright (C) 2018 Shinichi Takii' | ||
__version__ = '1.0.0' | ||
__license__ = 'BSD-3-Clause' | ||
__author__ = 'Shinichi Takii' | ||
__author_email__ = 'shinichi.takii@gmail.com' | ||
__url__ = 'http://github.com/shinichi-takii/ddlparse' | ||
|
||
__all__ = ['DdlParse', 'DdlParseTable', 'DdlParseColumn', 'DdlParseColumnDict'] |
Oops, something went wrong.