Transform column and table name to desired one
Project description
SQL Refactor
This library contains a class, Refactor
, for refactoring a SQL with a given knowledge of tables and column names mapping.
Structur of the knowledge
The knowledge is a dictionary containing the mapping of old_table
-new_table
and corresponding old_column
-new_column
.
The structure of the knowledge:
{
"old_table_name":
{
"new_table": "new_table_name",
"column_knowledge":
{
"column_1" : "new_column_1",
"column_2" : "new_column_2",
}
"preserved" : boolean
},
.
.
.
}
How to use
Code sample:
from sql_refactor import Refactor
# refer to Structure of Knowledge
knowledge = KNOWLEDGE
refactor = Refactor(knowledge)
refactor.refactor('''SELECT column_1, column_2 FROM old_table_name''')
new_query = refactor.result()
Result:
SELECT
new_column_1 AS column_1,
new_column_2 AS column_2
FROM
`new_table_name`
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-refactor-0.0.1.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for sql_refactor-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79ef76927f710f8a33fbcd68a3a9e7ac394caadf9e872ca10ea45c04b17ed00e |
|
MD5 | 1d5686794055b328e2f6aaa0d839d23c |
|
BLAKE2b-256 | e54dcfb8ce02b43e220d3391abb0a325f1ad1be1babddd5143fa77fb4b649acf |