gitdata-lib 0.0.17__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.
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/CHANGELOG.md +7 -0
- gitdata_lib-0.0.18/PKG-INFO +228 -0
- gitdata_lib-0.0.18/README.md +181 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/__init__.py +1 -1
- gitdata_lib-0.0.18/gitdata/__version__.py +1 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/common.py +2 -2
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/sqlite3.py +22 -2
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/utils.py +5 -2
- gitdata_lib-0.0.18/gitdata_lib.egg-info/PKG-INFO +228 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/requires.txt +2 -2
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/requirements.txt +2 -2
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/setup.py +4 -1
- gitdata_lib-0.0.17/PKG-INFO +0 -258
- gitdata_lib-0.0.17/README.md +0 -214
- gitdata_lib-0.0.17/gitdata/__version__.py +0 -1
- gitdata_lib-0.0.17/gitdata_lib.egg-info/PKG-INFO +0 -258
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/LICENSE +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/MANIFEST.in +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/assets/README.md +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/buckets.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/cli/__init__.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/cli/gitdata_get.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/cli/gitdata_init.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/cli/gitdata_ls.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/cli/gitdata_scan.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/cli/gitdata_secrets.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/config.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/connectors/__init__.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/connectors/common.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/connectors/fake.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/connectors/gitlab.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/connectors/http.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/connectors/local.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/connectors/tabular.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/__init__.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/mysql.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/mysql_setup.sql +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/mysql_setup_test_database.sql +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/oracle.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/postgresql.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/sqlite3_setup.sql +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/database/sqlite3_setup_test_data.sql +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/digester.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/encryption.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/ext/__init__.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/ext/connectors/__init__.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/graphs.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/inspection.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/json.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/queues.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/repositories.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/secrets.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/solutions.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/sql.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/stores/__init__.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/stores/common.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/stores/entities.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/stores/facts.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata/stores/tables.py +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/SOURCES.txt +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/dependency_links.txt +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/entry_points.txt +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/gitdata_lib.egg-info/top_level.txt +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/setup.cfg +0 -0
- {gitdata_lib-0.0.17 → gitdata_lib-0.0.18}/tests/test_blob.py +0 -0
|
@@ -6,6 +6,13 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
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
|
+
|
|
9
16
|
## [v0.0.17] - 2026-09-28
|
|
10
17
|
- add direct `gitdata ls` and streaming `gitdata scan` for CSV, SQLite, and MariaDB refs without digestion or storage
|
|
11
18
|
- allow `gitdata ls` on a MariaDB server ref to list databases visible to the user
|
|
@@ -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
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.0.18'
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
A database module that does less.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
import collections
|
|
9
|
+
import collections.abc
|
|
10
10
|
import inspect
|
|
11
11
|
import logging
|
|
12
12
|
import os
|
|
@@ -134,7 +134,7 @@ class Database:
|
|
|
134
134
|
"""test for a sequence type that is not a string"""
|
|
135
135
|
if isinstance(obj, (str, bytes)):
|
|
136
136
|
return False
|
|
137
|
-
return isinstance(obj, collections.Sequence)
|
|
137
|
+
return isinstance(obj, collections.abc.Sequence)
|
|
138
138
|
|
|
139
139
|
if self.paramstyle == 'qmark':
|
|
140
140
|
if not many and len(args) == 1 and hasattr(args[0], 'items') and args[0]:
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
gitdata sqlite3 database
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
from datetime import date, datetime
|
|
5
6
|
from decimal import Decimal
|
|
6
7
|
import sqlite3
|
|
7
8
|
import logging
|
|
@@ -57,13 +58,32 @@ class Sqlite3Database(Database):
|
|
|
57
58
|
return str(value)
|
|
58
59
|
|
|
59
60
|
def convert_decimal(bytetext):
|
|
60
|
-
"""convert
|
|
61
|
-
Decimal values"""
|
|
61
|
+
"""convert byte-string decimal values to Decimal values"""
|
|
62
62
|
return Decimal(bytetext.decode())
|
|
63
63
|
|
|
64
|
+
def adapt_date(value):
|
|
65
|
+
"""Store dates using the ISO 8601 representation."""
|
|
66
|
+
return value.isoformat()
|
|
67
|
+
|
|
68
|
+
def adapt_datetime(value):
|
|
69
|
+
"""Store datetimes using the historical SQLite representation."""
|
|
70
|
+
return value.isoformat(' ')
|
|
71
|
+
|
|
72
|
+
def convert_date(bytetext):
|
|
73
|
+
"""Restore ISO 8601 dates."""
|
|
74
|
+
return date.fromisoformat(bytetext.decode())
|
|
75
|
+
|
|
76
|
+
def convert_timestamp(bytetext):
|
|
77
|
+
"""Restore ISO 8601 timestamps."""
|
|
78
|
+
return datetime.fromisoformat(bytetext.decode())
|
|
79
|
+
|
|
64
80
|
kwargs.setdefault('isolation_level', None) # autocommit
|
|
65
81
|
sqlite3.register_adapter(Decimal, adapt_decimal)
|
|
66
82
|
sqlite3.register_converter('decimal', convert_decimal)
|
|
83
|
+
sqlite3.register_adapter(date, adapt_date)
|
|
84
|
+
sqlite3.register_adapter(datetime, adapt_datetime)
|
|
85
|
+
sqlite3.register_converter('date', convert_date)
|
|
86
|
+
sqlite3.register_converter('timestamp', convert_timestamp)
|
|
67
87
|
|
|
68
88
|
Database.__init__(self, sqlite3.connect, *args, **keyword_args)
|
|
69
89
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
gitdata utils
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import collections
|
|
5
|
+
import collections.abc
|
|
6
6
|
import datetime
|
|
7
7
|
import decimal
|
|
8
8
|
import inspect
|
|
@@ -46,6 +46,9 @@ def test_uid_maker(start=0):
|
|
|
46
46
|
return _new_id
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
test_uid_maker.__test__ = False
|
|
50
|
+
|
|
51
|
+
|
|
49
52
|
def id_for(*args):
|
|
50
53
|
"""Calculates a valid hyphenated id given an arbitrary string.
|
|
51
54
|
|
|
@@ -735,7 +738,7 @@ class RecordList(list):
|
|
|
735
738
|
return title + str(ItemList(rows, labels=labels)) + footer
|
|
736
739
|
|
|
737
740
|
|
|
738
|
-
class OrderedSet(collections.MutableSet):
|
|
741
|
+
class OrderedSet(collections.abc.MutableSet):
|
|
739
742
|
"""OrderedSet
|
|
740
743
|
|
|
741
744
|
A set that preserves the order of the elements
|