yhttp-dbmanager 2.8.1__tar.gz → 3.0.0__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.
- {yhttp_dbmanager-2.8.1/yhttp_dbmanager.egg-info → yhttp_dbmanager-3.0.0}/PKG-INFO +3 -3
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/README.md +2 -2
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/setup.py +2 -1
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/tests/test_dburi.py +17 -4
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp/ext/dbmanager/__init__.py +2 -2
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp/ext/dbmanager/cli.py +4 -4
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp/ext/dbmanager/dbmanager.py +3 -2
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp/ext/dbmanager/install.py +3 -3
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp/ext/dbmanager/uri.py +16 -7
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0/yhttp_dbmanager.egg-info}/PKG-INFO +3 -3
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/LICENSE +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/setup.cfg +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/tests/test_cli.py +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/tests/test_dbmanager.py +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/tests/test_install.py +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp_dbmanager.egg-info/SOURCES.txt +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp_dbmanager.egg-info/dependency_links.txt +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp_dbmanager.egg-info/requires.txt +0 -0
- {yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp_dbmanager.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: yhttp-dbmanager
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: Database manager command line interface and API for yhttp.
|
|
5
5
|
Home-page: http://github.com/yhttp/yhttp-dbmanager
|
|
6
6
|
Author: Vahid Mardani
|
|
@@ -33,7 +33,7 @@ API.
|
|
|
33
33
|
## Contribution
|
|
34
34
|
|
|
35
35
|
### Dependencies
|
|
36
|
-
Install `
|
|
36
|
+
Install `postgresql` brefore use of this project.
|
|
37
37
|
```bash
|
|
38
38
|
apt install postgresql
|
|
39
39
|
```
|
|
@@ -118,7 +118,7 @@ Execute:
|
|
|
118
118
|
```bash
|
|
119
119
|
make clean
|
|
120
120
|
```
|
|
121
|
-
to clean-up previous dist
|
|
121
|
+
to clean-up previous `dist/*` and `build/*` directories.
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
### PyPI
|
|
@@ -6,7 +6,7 @@ API.
|
|
|
6
6
|
## Contribution
|
|
7
7
|
|
|
8
8
|
### Dependencies
|
|
9
|
-
Install `
|
|
9
|
+
Install `postgresql` brefore use of this project.
|
|
10
10
|
```bash
|
|
11
11
|
apt install postgresql
|
|
12
12
|
```
|
|
@@ -91,7 +91,7 @@ Execute:
|
|
|
91
91
|
```bash
|
|
92
92
|
make clean
|
|
93
93
|
```
|
|
94
|
-
to clean-up previous dist
|
|
94
|
+
to clean-up previous `dist/*` and `build/*` directories.
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
### PyPI
|
|
@@ -11,7 +11,7 @@ def test_dburi():
|
|
|
11
11
|
assert uri.user == 'bar'
|
|
12
12
|
assert uri.password == 'baz'
|
|
13
13
|
assert uri.host == 'qux'
|
|
14
|
-
assert uri.
|
|
14
|
+
assert uri.database == 'quux.thud'
|
|
15
15
|
assert uri.dumps() == uristr
|
|
16
16
|
|
|
17
17
|
# Invalid uri
|
|
@@ -26,7 +26,7 @@ def test_dburi():
|
|
|
26
26
|
assert uri.user == 'bar'
|
|
27
27
|
assert uri.password == ''
|
|
28
28
|
assert uri.host == 'qux'
|
|
29
|
-
assert uri.
|
|
29
|
+
assert uri.database == 'quux.thud'
|
|
30
30
|
assert uri.dumps() == uristr
|
|
31
31
|
|
|
32
32
|
# Without username and password
|
|
@@ -36,7 +36,7 @@ def test_dburi():
|
|
|
36
36
|
assert uri.user == ''
|
|
37
37
|
assert uri.password == ''
|
|
38
38
|
assert uri.host == 'qux'
|
|
39
|
-
assert uri.
|
|
39
|
+
assert uri.database == 'quux.thud'
|
|
40
40
|
assert uri.dumps() == uristr
|
|
41
41
|
|
|
42
42
|
# Without username, password and host
|
|
@@ -46,5 +46,18 @@ def test_dburi():
|
|
|
46
46
|
assert uri.user == ''
|
|
47
47
|
assert uri.password == ''
|
|
48
48
|
assert uri.host == ''
|
|
49
|
-
assert uri.
|
|
49
|
+
assert uri.database == 'quux.thud'
|
|
50
50
|
assert uri.dumps() == uristr
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_dburi_todict():
|
|
54
|
+
uristr = 'foo://bar:baz@qux/quux.thud'
|
|
55
|
+
uri = DatabaseURI.loads(uristr)
|
|
56
|
+
|
|
57
|
+
assert uri.todict() == dict(
|
|
58
|
+
provider='foo',
|
|
59
|
+
user='bar',
|
|
60
|
+
password='baz',
|
|
61
|
+
host='qux',
|
|
62
|
+
database='quux.thud'
|
|
63
|
+
)
|
|
@@ -50,7 +50,7 @@ class DatabaseAdministrativeCommand(SubCommand):
|
|
|
50
50
|
user=args.user,
|
|
51
51
|
password=password,
|
|
52
52
|
host=args.host,
|
|
53
|
-
|
|
53
|
+
database=args.database
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
def getappdbinfo(self, args):
|
|
@@ -65,7 +65,7 @@ class CreateDatabase(DatabaseAdministrativeCommand):
|
|
|
65
65
|
|
|
66
66
|
def __call__(self, args):
|
|
67
67
|
uri = self.getappdbinfo(args)
|
|
68
|
-
self.getdbmanager(args).create(uri.
|
|
68
|
+
self.getdbmanager(args).create(uri.database, owner=uri.user)
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
class DropDatabase(DatabaseAdministrativeCommand):
|
|
@@ -74,10 +74,10 @@ class DropDatabase(DatabaseAdministrativeCommand):
|
|
|
74
74
|
|
|
75
75
|
def __call__(self, args):
|
|
76
76
|
uri = self.getappdbinfo(args)
|
|
77
|
-
self.getdbmanager(args).drop(uri.
|
|
77
|
+
self.getdbmanager(args).drop(uri.database)
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
class
|
|
80
|
+
class DatabaseCommand(SubCommand):
|
|
81
81
|
__command__ = 'database'
|
|
82
82
|
__aliases__ = ['db']
|
|
83
83
|
__arguments__ = [
|
|
@@ -29,10 +29,11 @@ class DatabaseManager(metaclass=abc.ABCMeta):
|
|
|
29
29
|
|
|
30
30
|
class PostgresqlManager(DatabaseManager):
|
|
31
31
|
|
|
32
|
-
def __init__(self, host=None,
|
|
32
|
+
def __init__(self, host=None, database='postgres', user=None,
|
|
33
|
+
password=None):
|
|
33
34
|
self.connection = psycopg2.connect(
|
|
34
35
|
host=host,
|
|
35
|
-
dbname=
|
|
36
|
+
dbname=database,
|
|
36
37
|
user=user,
|
|
37
38
|
password=password
|
|
38
39
|
)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
from .cli import
|
|
1
|
+
from .cli import DatabaseCommand
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def install(app, cliarguments=None):
|
|
5
|
-
app.cliarguments.append(
|
|
5
|
+
app.cliarguments.append(DatabaseCommand)
|
|
6
6
|
if cliarguments:
|
|
7
|
-
|
|
7
|
+
DatabaseCommand.__arguments__.extend(cliarguments)
|
|
8
8
|
|
|
9
9
|
@app.when
|
|
10
10
|
def ready(app):
|
|
@@ -3,24 +3,24 @@ import re
|
|
|
3
3
|
|
|
4
4
|
URIPATTERN = re.compile(
|
|
5
5
|
r'(?P<provider>.*)://(?P<user>.*):(?P<password>.*)@(?P<host>.*)/'
|
|
6
|
-
r'(?P<
|
|
6
|
+
r'(?P<database>.*)'
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class DatabaseURI:
|
|
11
|
-
def __init__(self, provider,
|
|
11
|
+
def __init__(self, provider, database, host='', user='', password=''):
|
|
12
12
|
assert provider
|
|
13
|
-
assert
|
|
13
|
+
assert database
|
|
14
14
|
|
|
15
15
|
self.provider = provider
|
|
16
16
|
self.host = host
|
|
17
|
-
self.
|
|
17
|
+
self.database = database
|
|
18
18
|
self.user = user
|
|
19
19
|
self.password = password
|
|
20
20
|
|
|
21
21
|
def dumps(self):
|
|
22
22
|
return f'{self.provider}://{self.user}:{self.password}@{self.host}' \
|
|
23
|
-
f'/{self.
|
|
23
|
+
f'/{self.database}'
|
|
24
24
|
|
|
25
25
|
@classmethod
|
|
26
26
|
def loads(cls, uri):
|
|
@@ -31,11 +31,20 @@ class DatabaseURI:
|
|
|
31
31
|
u = match.groupdict()
|
|
32
32
|
|
|
33
33
|
assert u.get('provider')
|
|
34
|
-
assert u.get('
|
|
34
|
+
assert u.get('database')
|
|
35
35
|
return cls(
|
|
36
36
|
u.get('provider'),
|
|
37
|
-
u.get('
|
|
37
|
+
u.get('database'),
|
|
38
38
|
u.get('host'),
|
|
39
39
|
u.get('user'),
|
|
40
40
|
u.get('password'),
|
|
41
41
|
)
|
|
42
|
+
|
|
43
|
+
def todict(self):
|
|
44
|
+
return dict(
|
|
45
|
+
provider=self.provider,
|
|
46
|
+
user=self.user,
|
|
47
|
+
password=self.password,
|
|
48
|
+
host=self.host,
|
|
49
|
+
database=self.database
|
|
50
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: yhttp-dbmanager
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: Database manager command line interface and API for yhttp.
|
|
5
5
|
Home-page: http://github.com/yhttp/yhttp-dbmanager
|
|
6
6
|
Author: Vahid Mardani
|
|
@@ -33,7 +33,7 @@ API.
|
|
|
33
33
|
## Contribution
|
|
34
34
|
|
|
35
35
|
### Dependencies
|
|
36
|
-
Install `
|
|
36
|
+
Install `postgresql` brefore use of this project.
|
|
37
37
|
```bash
|
|
38
38
|
apt install postgresql
|
|
39
39
|
```
|
|
@@ -118,7 +118,7 @@ Execute:
|
|
|
118
118
|
```bash
|
|
119
119
|
make clean
|
|
120
120
|
```
|
|
121
|
-
to clean-up previous dist
|
|
121
|
+
to clean-up previous `dist/*` and `build/*` directories.
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
### PyPI
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{yhttp_dbmanager-2.8.1 → yhttp_dbmanager-3.0.0}/yhttp_dbmanager.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|