Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
The SQL Data Dependency Tool (sqldd
) is a tookit used for analyzing dependencies between rows in a database. Given a table and a primary key, it recursively analyzes foreign keys to generate a map of all downstream tables and foreign keys the initial "root row" depends on.
.. image:: https://travis-ci.org/rkeilty/sql-data-dependency.svg?branch=master :target: https://travis-ci.org/rkeilty/sql-data-dependency
The sqldd
module is published on the Python Package Index <https://pypi.python.org/pypi/sqldd>
__, so you can
install it using pip
or easy_install
.
::
pip install sqldd
Or:
::
easy_install sqldd
It installs a sqldd
module in the path for simple shell usage.
The most common usage of the tool is from the shell with sqldd
.
For example, to find dependencies of row 53 in table A: ::
$: sqldd A 53 --database sqldd_db --pretty
{
"A": [
53
],
"D': [
1,
2,
20
],
"M': [
48
]
}
This indicates that in the complete dependency tree for that row, tables D
and M
have rows that matter to foreign keys. This may not be a direct child dependency of A
, but possibly a sub-dependency (A:53 --> D:1 --> M:48
)
For more complex analysis, where one may want to look at multiple tables/rows, a JSON file can be specified with table names as keys, and values are arrays of primary keys.
::
{
"A": [53],
"another_table": [1, 4, 10],
"one_more_table": ["string_pk_1", "string_pk_2"]
}
Now invoking will give more output:
::
$: sqldd --json input.json --database sqldd_db --pretty
{
"A": [53],
"D": [1, 2, 20],
"M": [48],
"P": [800, 908],
"another_table": [1, 4, 10, 22, 28],
"one_more_table": ["string_pk_1", "string_pk_2", "string_pk_4444"]
}
A docker image of the tool is also available. It is invoked using docker run
the same way as the pip command.
::
$: docker run --rm rkeilty/sqldd A 53 --database my_db --pretty
{
"A": [
53
],
"D': [
1,
2,
20
],
"M': [
48
]
}
::
usage: sqldd [-h] [--json JSON_FILE] [--server SERVER] [--port PORT]
--database DATABASE [--username USERNAME] [--password PASSWORD]
[--pretty] [--sqldump] [--sqldump_table_defs]
[table] [primary_key]
SQL Data Dependency Tool
One of either ([table][primary_key]) or [--json] is required.
positional arguments:
table Table to analyze
primary_key Primary key for row in table to analyze
optional arguments:
-h, --help show this help message and exit
--json JSON_FILE File containing tables and rows to analyze
--server SERVER Database server
--port PORT Database port
--database DATABASE Database name
--username USERNAME Database username
--password PASSWORD Database password
--pretty Pretty print the output
--sqldump Generate a sql dump file of all dependencies
--sqldump_table_defs Dump _all_ table defs, even those without
dependencies. Useful for constructing skeleton DBs.
sqldd
is licensed under the terms of the 3-clause BSD license.
All contributions are welcome, including but not limited to:
If you encounter any errors in the code, please file an issue on github: https://github.com/rkeilty/sql-data-dependency/issues.
Release Date: 2017-02-07
Changes:
Release Date: 2017-02-03
Changes:
Release Date: 2017-01-28
Changes:
Release Date: 2017-01-27
Changes:
FAQs
A toolkit for analyzing dependencies in SQL databases.
We found that sqldd demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.