gitdata-lib 0.0.12__tar.gz → 0.0.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. gitdata_lib-0.0.18/CHANGELOG.md +76 -0
  2. gitdata_lib-0.0.18/PKG-INFO +228 -0
  3. gitdata_lib-0.0.18/README.md +181 -0
  4. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/__init__.py +1 -1
  5. gitdata_lib-0.0.18/gitdata/__version__.py +1 -0
  6. gitdata_lib-0.0.18/gitdata/cli/__init__.py +114 -0
  7. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/cli/gitdata_get.py +5 -3
  8. gitdata_lib-0.0.18/gitdata/cli/gitdata_init.py +22 -0
  9. gitdata_lib-0.0.18/gitdata/cli/gitdata_ls.py +84 -0
  10. gitdata_lib-0.0.18/gitdata/cli/gitdata_scan.py +150 -0
  11. gitdata_lib-0.0.18/gitdata/cli/gitdata_secrets.py +129 -0
  12. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/config.py +7 -2
  13. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/connectors/common.py +35 -12
  14. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/connectors/http.py +24 -8
  15. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/connectors/local.py +5 -5
  16. gitdata_lib-0.0.18/gitdata/connectors/tabular.py +629 -0
  17. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/__init__.py +13 -0
  18. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/common.py +5 -4
  19. gitdata_lib-0.0.18/gitdata/database/oracle.py +99 -0
  20. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/sqlite3.py +22 -2
  21. gitdata_lib-0.0.18/gitdata/digester.py +170 -0
  22. gitdata_lib-0.0.18/gitdata/encryption.py +25 -0
  23. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/graphs.py +10 -2
  24. gitdata_lib-0.0.18/gitdata/inspection.py +166 -0
  25. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/queues.py +14 -0
  26. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/repositories.py +33 -9
  27. gitdata_lib-0.0.18/gitdata/secrets.py +359 -0
  28. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/stores/facts.py +12 -26
  29. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/utils.py +5 -2
  30. gitdata_lib-0.0.18/gitdata_lib.egg-info/PKG-INFO +228 -0
  31. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/SOURCES.txt +10 -1
  32. gitdata_lib-0.0.18/gitdata_lib.egg-info/requires.txt +12 -0
  33. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/requirements.txt +3 -2
  34. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/setup.py +8 -3
  35. gitdata_lib-0.0.18/tests/test_blob.py +42 -0
  36. gitdata_lib-0.0.12/CHANGELOG.md +0 -0
  37. gitdata_lib-0.0.12/PKG-INFO +0 -36
  38. gitdata_lib-0.0.12/README.md +0 -5
  39. gitdata_lib-0.0.12/gitdata/__version__.py +0 -1
  40. gitdata_lib-0.0.12/gitdata/cli/__init__.py +0 -70
  41. gitdata_lib-0.0.12/gitdata/cli/gitdata_scan.py +0 -94
  42. gitdata_lib-0.0.12/gitdata/digester.py +0 -94
  43. gitdata_lib-0.0.12/gitdata_lib.egg-info/PKG-INFO +0 -36
  44. gitdata_lib-0.0.12/gitdata_lib.egg-info/requires.txt +0 -8
  45. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/LICENSE +0 -0
  46. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/MANIFEST.in +0 -0
  47. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/assets/README.md +0 -0
  48. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/buckets.py +0 -0
  49. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/connectors/__init__.py +0 -0
  50. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/connectors/fake.py +0 -0
  51. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/connectors/gitlab.py +0 -0
  52. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/mysql.py +0 -0
  53. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/mysql_setup.sql +0 -0
  54. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/mysql_setup_test_database.sql +0 -0
  55. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/postgresql.py +0 -0
  56. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/sqlite3_setup.sql +0 -0
  57. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/database/sqlite3_setup_test_data.sql +0 -0
  58. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/ext/__init__.py +0 -0
  59. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/ext/connectors/__init__.py +0 -0
  60. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/json.py +0 -0
  61. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/solutions.py +0 -0
  62. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/sql.py +0 -0
  63. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/stores/__init__.py +0 -0
  64. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/stores/common.py +0 -0
  65. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/stores/entities.py +0 -0
  66. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata/stores/tables.py +0 -0
  67. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/dependency_links.txt +0 -0
  68. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/entry_points.txt +0 -0
  69. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/top_level.txt +0 -0
  70. {gitdata_lib-0.0.12 → gitdata_lib-0.0.18}/setup.cfg +0 -0
@@ -0,0 +1,76 @@
1
+ # Changelog
2
+ All notable changes to this project are documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [v0.0.18] - 2026-09-28
10
+ - support and test Python 3.9 through 3.12
11
+ - replace removed `collections` aliases with `collections.abc`
12
+ - update PostgreSQL and CLI dependencies for Python 3.12
13
+ - register explicit SQLite date and timestamp adapters and converters
14
+ - run pytest-based CI and local test workflows across supported Python versions and database integrations
15
+
16
+ ## [v0.0.17] - 2026-09-28
17
+ - add direct `gitdata ls` and streaming `gitdata scan` for CSV, SQLite, and MariaDB refs without digestion or storage
18
+ - allow `gitdata ls` on a MariaDB server ref to list databases visible to the user
19
+ - accept canonical `database.table` selection in MariaDB/MySQL refs while retaining `#table` compatibility
20
+ - use `database-file/table.column` SQLite refs without fragment selectors
21
+ - eagerly count database rows before sampling unless `gitdata scan --no-count` is supplied
22
+ - allow SQLite column refs to scan one column and behave as leaves under `gitdata ls`
23
+ - format `gitdata scan` as a terminal-width-aware table with aligned numeric columns and bounded values
24
+ - default omitted MariaDB usernames to the current OS user and attempt passwordless authentication when no password environment variable is specified
25
+ - add reusable CSV, SQLite, and `mysqldump` examples for manual inspection
26
+ - exit cleanly without a traceback when a command is interrupted with Ctrl+C
27
+ - announce `gitdata scan` after ref validation and connection, immediately before sampling
28
+ - add `gitdata ls -l` database/table statistics, column schema, and index details
29
+ - hide database-specific system objects from `gitdata ls` unless `-a` is supplied
30
+ - distinguish node relationships from literal values with structural predicates
31
+ - preserve repeated predicate values when reading graph nodes
32
+ - escape colliding source predicates and omit factless values without dangling relationships
33
+ - verify multiple source graphs retain independent roots in memory and SQLite repositories
34
+ - require re-ingestion of older graph facts whose unprefixed relationships cannot be distinguished from literal IDs
35
+
36
+ ## [v0.0.16] - 2026-09-19
37
+ - add optional Oracle Database support with `python-oracledb` Thin mode and live CI integration tests
38
+ - add initial encryption module and unit tests
39
+ - refactor secrets module into a backend-agnostic core with pluggable storage
40
+ - add `GITDATA_ENCRYPTION_KEY` and docker `/run/secrets` key resolution for secrets
41
+ - mask secret values by default in secrets listing APIs
42
+ - persist secrets in the local `.gitdata` repository via EntityStore
43
+ - add `gitdata secret` command to list, get, set, and delete secrets
44
+ - add secrets resolve API that hard-fails listing missing names
45
+ - add `gitdata secret status`, `resolve`, and `clear` for share handoff
46
+ - keep secret values out of logs, HTTP facts, and routine CLI output
47
+ - rename CLI command to `gitdata secret` (`secrets` remains an alias)
48
+ - add `gitdata init` command to initialize repositories
49
+ - switch local repository storage to a single `.gitdata` sqlite file
50
+
51
+ ## [v0.0.15] - 2025-08-03
52
+ - add secrets module stub
53
+
54
+ ## [v0.0.14] - 2025-08-03
55
+ - add support for environment variable style config keys
56
+
57
+ ## [v0.0.13] - 2025-08-03
58
+ - make config filename a constant
59
+ - improve CLI help and `get` output readability
60
+ - expand queue tests and database-specific test configuration
61
+
62
+ ## [v0.0.12] - 2024-05-01
63
+ - add `scan` command and HTTP connector support
64
+ - add SQL module and related tests
65
+ - improve CLI behavior and test/CI setup
66
+
67
+ ## [v0.0.11] - 2021-12-31
68
+ - refactor CLI and connector internals
69
+ - add fake and local connector support
70
+ - continue datastore and graph/facts foundation work
71
+
72
+ ## [v0.0.3] - 2021-10-10
73
+ - add CLI entrypoint and related command wiring
74
+
75
+ ## [v0.0.1] - 2021-10-09
76
+ - initial packaged release with config, database, stores, queues, and connectors
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: gitdata-lib
3
+ Version: 0.0.18
4
+ Summary: Data extraction and analysis library
5
+ Home-page: https://github.com/gitdata/gitdata-lib
6
+ Author: DSI Labs
7
+ Author-email: support@gitdata.com
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Topic :: Database :: Front-Ends
22
+ Requires-Python: >=3.9,<3.13
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: python-decouple>=3.4
26
+ Requires-Dist: Unipath>=1.1
27
+ Requires-Dist: PyMySQL==0.10.1
28
+ Requires-Dist: psycopg2-binary==2.9.10
29
+ Requires-Dist: python-dotenv
30
+ Requires-Dist: requests
31
+ Requires-Dist: docopt-ng<1,>=0.9
32
+ Requires-Dist: faker
33
+ Requires-Dist: cryptography
34
+ Provides-Extra: oracle
35
+ Requires-Dist: oracledb<4,>=1.3; extra == "oracle"
36
+ Dynamic: author
37
+ Dynamic: author-email
38
+ Dynamic: classifier
39
+ Dynamic: description
40
+ Dynamic: description-content-type
41
+ Dynamic: home-page
42
+ Dynamic: license-file
43
+ Dynamic: provides-extra
44
+ Dynamic: requires-dist
45
+ Dynamic: requires-python
46
+ Dynamic: summary
47
+
48
+ # GitData
49
+
50
+ GitData gives you one set of commands for exploring files and databases.
51
+ List what is inside a source with `gitdata ls`, then preview its data with
52
+ `gitdata scan`.
53
+
54
+ ## Install
55
+
56
+ GitData supports Python 3.9 through 3.12.
57
+
58
+ ```bash
59
+ python3 -m pip install gitdata-lib
60
+ ```
61
+
62
+ Oracle support is optional:
63
+
64
+ ```bash
65
+ python3 -m pip install 'gitdata-lib[oracle]'
66
+ ```
67
+
68
+ ## Explore a data source
69
+
70
+ The same two commands work across CSV files, SQLite databases, and
71
+ MariaDB/MySQL databases:
72
+
73
+ ```bash
74
+ gitdata ls <source>
75
+ gitdata scan <source>
76
+ ```
77
+
78
+ Use `-l` for a detailed listing, `-a` to include system objects, and `--limit`
79
+ to choose how many rows to preview.
80
+
81
+ ## CSV
82
+
83
+ List the columns in a CSV file:
84
+
85
+ ```bash
86
+ gitdata ls examples/locations-headered.csv
87
+ ```
88
+
89
+ Preview its rows:
90
+
91
+ ```bash
92
+ gitdata scan --limit 10 examples/locations-headered.csv
93
+ ```
94
+
95
+ ## SQLite
96
+
97
+ Start with the database file, then move into a table or column:
98
+
99
+ ```bash
100
+ # List tables
101
+ gitdata ls examples/inspection.sqlite
102
+
103
+ # Show table details
104
+ gitdata ls -l examples/inspection.sqlite/customers
105
+
106
+ # Preview rows
107
+ gitdata scan --limit 5 examples/inspection.sqlite/customers
108
+
109
+ # Examine one column
110
+ gitdata scan --limit 5 examples/inspection.sqlite/customers.email
111
+ ```
112
+
113
+ SQLite references follow this shape:
114
+
115
+ ```text
116
+ path/to/database.sqlite
117
+ path/to/database.sqlite/table
118
+ path/to/database.sqlite/table.column
119
+ ```
120
+
121
+ ## MariaDB and MySQL
122
+
123
+ Keep passwords in environment variables instead of putting them in database
124
+ references:
125
+
126
+ ```bash
127
+ export GITDATA_DB_PASSWORD='your-password'
128
+
129
+ SERVER='mysql://user@db.example.com?password_env=GITDATA_DB_PASSWORD'
130
+ DATABASE='mysql://user@db.example.com/sales?password_env=GITDATA_DB_PASSWORD'
131
+ TABLE='mysql://user@db.example.com/sales.orders?password_env=GITDATA_DB_PASSWORD'
132
+ ```
133
+
134
+ Explore the server, database, and table with the same commands:
135
+
136
+ ```bash
137
+ # List databases
138
+ gitdata ls "$SERVER"
139
+
140
+ # List tables
141
+ gitdata ls "$DATABASE"
142
+
143
+ # Show columns and indexes
144
+ gitdata ls -l "$TABLE"
145
+
146
+ # Preview rows
147
+ gitdata scan --limit 10 "$TABLE"
148
+ ```
149
+
150
+ MariaDB/MySQL references follow this shape:
151
+
152
+ ```text
153
+ mysql://user@host
154
+ mysql://user@host/database
155
+ mysql://user@host/database.table
156
+ ```
157
+
158
+ If the username is omitted, GitData uses the current operating-system username.
159
+ Use `gitdata ls -a` when you also want to see system databases or tables.
160
+
161
+ ### Try the included MariaDB example
162
+
163
+ The repository includes `examples/mariadb.sql`. Load it into a disposable
164
+ MariaDB container:
165
+
166
+ ```bash
167
+ docker run --name gitdata-example-mariadb \
168
+ -e MARIADB_ROOT_PASSWORD=example \
169
+ -p 3307:3306 \
170
+ -d mariadb:10.7
171
+
172
+ until docker exec gitdata-example-mariadb \
173
+ mariadb-admin ping -h 127.0.0.1 -uroot -pexample --silent
174
+ do
175
+ sleep 1
176
+ done
177
+
178
+ docker exec -i gitdata-example-mariadb \
179
+ mariadb -uroot -pexample < examples/mariadb.sql
180
+
181
+ export GITDATA_EXAMPLE_PASSWORD=example
182
+ gitdata ls 'mysql://root@127.0.0.1:3307/gitdata_example?password_env=GITDATA_EXAMPLE_PASSWORD'
183
+ gitdata scan --limit 5 'mysql://root@127.0.0.1:3307/gitdata_example.customers?password_env=GITDATA_EXAMPLE_PASSWORD'
184
+ ```
185
+
186
+ Remove the example when finished:
187
+
188
+ ```bash
189
+ docker rm -f gitdata-example-mariadb
190
+ ```
191
+
192
+ ## Command reference
193
+
194
+ ```text
195
+ gitdata ls <source> list databases, tables, or columns
196
+ gitdata ls -l <source> show a detailed listing
197
+ gitdata ls -a <source> include system objects
198
+ gitdata scan <source> preview and profile data
199
+ gitdata scan --limit N ... preview at most N rows
200
+ ```
201
+
202
+ Run a command with `--help` for all options:
203
+
204
+ ```bash
205
+ gitdata ls --help
206
+ gitdata scan --help
207
+ ```
208
+
209
+ ## Oracle from Python
210
+
211
+ Use the optional Oracle driver through the Python API:
212
+
213
+ ```python
214
+ import os
215
+
216
+ from gitdata.database import connect
217
+
218
+ db = connect(
219
+ 'oracle',
220
+ host='127.0.0.1',
221
+ port=1521,
222
+ service_name='FREEPDB1',
223
+ user='app',
224
+ password=os.environ['ORACLE_PASSWORD'],
225
+ )
226
+
227
+ rows = list(db('SELECT 1 FROM dual'))
228
+ ```
@@ -0,0 +1,181 @@
1
+ # GitData
2
+
3
+ GitData gives you one set of commands for exploring files and databases.
4
+ List what is inside a source with `gitdata ls`, then preview its data with
5
+ `gitdata scan`.
6
+
7
+ ## Install
8
+
9
+ GitData supports Python 3.9 through 3.12.
10
+
11
+ ```bash
12
+ python3 -m pip install gitdata-lib
13
+ ```
14
+
15
+ Oracle support is optional:
16
+
17
+ ```bash
18
+ python3 -m pip install 'gitdata-lib[oracle]'
19
+ ```
20
+
21
+ ## Explore a data source
22
+
23
+ The same two commands work across CSV files, SQLite databases, and
24
+ MariaDB/MySQL databases:
25
+
26
+ ```bash
27
+ gitdata ls <source>
28
+ gitdata scan <source>
29
+ ```
30
+
31
+ Use `-l` for a detailed listing, `-a` to include system objects, and `--limit`
32
+ to choose how many rows to preview.
33
+
34
+ ## CSV
35
+
36
+ List the columns in a CSV file:
37
+
38
+ ```bash
39
+ gitdata ls examples/locations-headered.csv
40
+ ```
41
+
42
+ Preview its rows:
43
+
44
+ ```bash
45
+ gitdata scan --limit 10 examples/locations-headered.csv
46
+ ```
47
+
48
+ ## SQLite
49
+
50
+ Start with the database file, then move into a table or column:
51
+
52
+ ```bash
53
+ # List tables
54
+ gitdata ls examples/inspection.sqlite
55
+
56
+ # Show table details
57
+ gitdata ls -l examples/inspection.sqlite/customers
58
+
59
+ # Preview rows
60
+ gitdata scan --limit 5 examples/inspection.sqlite/customers
61
+
62
+ # Examine one column
63
+ gitdata scan --limit 5 examples/inspection.sqlite/customers.email
64
+ ```
65
+
66
+ SQLite references follow this shape:
67
+
68
+ ```text
69
+ path/to/database.sqlite
70
+ path/to/database.sqlite/table
71
+ path/to/database.sqlite/table.column
72
+ ```
73
+
74
+ ## MariaDB and MySQL
75
+
76
+ Keep passwords in environment variables instead of putting them in database
77
+ references:
78
+
79
+ ```bash
80
+ export GITDATA_DB_PASSWORD='your-password'
81
+
82
+ SERVER='mysql://user@db.example.com?password_env=GITDATA_DB_PASSWORD'
83
+ DATABASE='mysql://user@db.example.com/sales?password_env=GITDATA_DB_PASSWORD'
84
+ TABLE='mysql://user@db.example.com/sales.orders?password_env=GITDATA_DB_PASSWORD'
85
+ ```
86
+
87
+ Explore the server, database, and table with the same commands:
88
+
89
+ ```bash
90
+ # List databases
91
+ gitdata ls "$SERVER"
92
+
93
+ # List tables
94
+ gitdata ls "$DATABASE"
95
+
96
+ # Show columns and indexes
97
+ gitdata ls -l "$TABLE"
98
+
99
+ # Preview rows
100
+ gitdata scan --limit 10 "$TABLE"
101
+ ```
102
+
103
+ MariaDB/MySQL references follow this shape:
104
+
105
+ ```text
106
+ mysql://user@host
107
+ mysql://user@host/database
108
+ mysql://user@host/database.table
109
+ ```
110
+
111
+ If the username is omitted, GitData uses the current operating-system username.
112
+ Use `gitdata ls -a` when you also want to see system databases or tables.
113
+
114
+ ### Try the included MariaDB example
115
+
116
+ The repository includes `examples/mariadb.sql`. Load it into a disposable
117
+ MariaDB container:
118
+
119
+ ```bash
120
+ docker run --name gitdata-example-mariadb \
121
+ -e MARIADB_ROOT_PASSWORD=example \
122
+ -p 3307:3306 \
123
+ -d mariadb:10.7
124
+
125
+ until docker exec gitdata-example-mariadb \
126
+ mariadb-admin ping -h 127.0.0.1 -uroot -pexample --silent
127
+ do
128
+ sleep 1
129
+ done
130
+
131
+ docker exec -i gitdata-example-mariadb \
132
+ mariadb -uroot -pexample < examples/mariadb.sql
133
+
134
+ export GITDATA_EXAMPLE_PASSWORD=example
135
+ gitdata ls 'mysql://root@127.0.0.1:3307/gitdata_example?password_env=GITDATA_EXAMPLE_PASSWORD'
136
+ gitdata scan --limit 5 'mysql://root@127.0.0.1:3307/gitdata_example.customers?password_env=GITDATA_EXAMPLE_PASSWORD'
137
+ ```
138
+
139
+ Remove the example when finished:
140
+
141
+ ```bash
142
+ docker rm -f gitdata-example-mariadb
143
+ ```
144
+
145
+ ## Command reference
146
+
147
+ ```text
148
+ gitdata ls <source> list databases, tables, or columns
149
+ gitdata ls -l <source> show a detailed listing
150
+ gitdata ls -a <source> include system objects
151
+ gitdata scan <source> preview and profile data
152
+ gitdata scan --limit N ... preview at most N rows
153
+ ```
154
+
155
+ Run a command with `--help` for all options:
156
+
157
+ ```bash
158
+ gitdata ls --help
159
+ gitdata scan --help
160
+ ```
161
+
162
+ ## Oracle from Python
163
+
164
+ Use the optional Oracle driver through the Python API:
165
+
166
+ ```python
167
+ import os
168
+
169
+ from gitdata.database import connect
170
+
171
+ db = connect(
172
+ 'oracle',
173
+ host='127.0.0.1',
174
+ port=1521,
175
+ service_name='FREEPDB1',
176
+ user='app',
177
+ password=os.environ['ORACLE_PASSWORD'],
178
+ )
179
+
180
+ rows = list(db('SELECT 1 FROM dual'))
181
+ ```
@@ -1,4 +1,4 @@
1
- """
1
+ r"""
2
2
  ____ _ _ ____ _
3
3
  / ___(_) |_| _ \ __ _| |_ __ _
4
4
  | | _| | __| | | |/ _` | __/ _` |
@@ -0,0 +1 @@
1
+ __version__ = '0.0.18'
@@ -0,0 +1,114 @@
1
+ """
2
+ usage: gitdata [options] <command> [<args>...]
3
+
4
+ options:
5
+ -h, --help show help
6
+ -V, --version print version
7
+ -d, --debug debug
8
+
9
+ The most commonly used gitdata commands are:
10
+ init initialize a local gitdata repository
11
+ fetch fetch data to the local reposotiry
12
+ get get data
13
+ ls list immediate children of a ref
14
+ scan scan data
15
+ secret manage repository secrets
16
+
17
+ See 'gitdata help <command>' for more information on a specific command.
18
+ """
19
+
20
+ import importlib
21
+ import logging
22
+ import sys
23
+
24
+ from docopt import docopt
25
+
26
+ import gitdata
27
+ from gitdata.utils import trim
28
+
29
+
30
+ root_logger = logging.getLogger()
31
+
32
+
33
+ def print_help(doc):
34
+ """Print help text"""
35
+ print(trim(doc))
36
+
37
+
38
+ def get_module_doc(name):
39
+ if name == 'secret':
40
+ name = 'secrets'
41
+ module_name = 'gitdata.cli.gitdata_' + name
42
+ try:
43
+ result = importlib.import_module(module_name).__doc__
44
+ except ModuleNotFoundError:
45
+ result = f'no help on topic {name!r}'
46
+ return result
47
+
48
+
49
+ def main():
50
+ """CLI entry point with clean interrupt handling."""
51
+ try:
52
+ _main()
53
+ except KeyboardInterrupt:
54
+ print('\nInterrupted.', file=sys.stderr)
55
+ raise SystemExit(130)
56
+
57
+
58
+ def _main():
59
+ """Parse and dispatch a CLI command."""
60
+
61
+ if len(sys.argv) == 1:
62
+ print_help(__doc__)
63
+ sys.exit()
64
+
65
+ args = docopt(
66
+ __doc__,
67
+ version='gitdata version {}'.format(gitdata.__version__),
68
+ options_first=True
69
+ )
70
+
71
+ if args['--debug']:
72
+ print(args)
73
+ root_logger.setLevel(logging.DEBUG)
74
+
75
+ argv = [args['<command>']] + args['<args>']
76
+ command = args['<command>']
77
+
78
+ if command == 'help':
79
+ if args['<args>']:
80
+ topic = args['<args>'][0]
81
+ doc = get_module_doc(topic)
82
+ else:
83
+ doc = __doc__
84
+ print_help(doc)
85
+ sys.exit()
86
+
87
+ elif command == 'init':
88
+ from gitdata.cli.gitdata_init import init, __doc__ as doc
89
+ args = docopt(doc, argv=argv)
90
+ init(args)
91
+
92
+ elif command == 'get':
93
+ from gitdata.cli.gitdata_get import get, __doc__ as doc
94
+ args = docopt(doc, argv=argv)
95
+ get(args)
96
+
97
+ elif command == 'ls':
98
+ from gitdata.cli.gitdata_ls import ls_to_console, __doc__ as doc
99
+ args = docopt(doc, argv=argv)
100
+ ls_to_console(args)
101
+
102
+ elif command == 'scan':
103
+ from gitdata.cli.gitdata_scan import scan_to_console, __doc__ as doc
104
+ args = docopt(doc, argv=argv)
105
+ scan_to_console(args)
106
+
107
+ elif command in ('secret', 'secrets'):
108
+ from gitdata.cli.gitdata_secrets import secrets, __doc__ as doc
109
+ argv[0] = 'secret'
110
+ args = docopt(doc, argv=argv)
111
+ secrets(args)
112
+
113
+ else:
114
+ exit("%r is not a gitdata command. See 'gitdata help'." % args['<command>'])
@@ -14,9 +14,11 @@ def get(args):
14
14
  if args['<ref>']:
15
15
  for ref in args['<ref>']:
16
16
  print('getting', ref)
17
- pprint(
18
- gitdata.connectors.common.get(ref),
19
- )
17
+ result = gitdata.connectors.common.get(ref)
18
+ if isinstance(result, dict):
19
+ max_len = max(map(len, result.keys())) + 3
20
+ for k, v in result.items():
21
+ print('%s%s: %s' % (k, '.' * (max_len - len(k)), v))
20
22
  else:
21
23
  print(__doc__)
22
24
  print(args)
@@ -0,0 +1,22 @@
1
+ """
2
+ usage: gitdata init [<path>]
3
+
4
+ options:
5
+ -h, --help
6
+ """
7
+
8
+ import gitdata.repositories
9
+
10
+
11
+ def init(args):
12
+ """Initialize a gitdata repository."""
13
+ path = args['<path>'] or '.'
14
+ try:
15
+ repository_path, created = gitdata.repositories.init_repository(path)
16
+ except ValueError as error:
17
+ raise SystemExit('fatal: {}'.format(error))
18
+
19
+ if created:
20
+ print('Initialized empty GitData repository in {}'.format(repository_path))
21
+ else:
22
+ print('GitData repository already initialized in {}'.format(repository_path))