pycopg 0.1.0__py3-none-any.whl
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.
- pycopg/__init__.py +89 -0
- pycopg/async_database.py +736 -0
- pycopg/base.py +194 -0
- pycopg/config.py +244 -0
- pycopg/database.py +2255 -0
- pycopg/exceptions.py +38 -0
- pycopg/migrations.py +388 -0
- pycopg/pool.py +416 -0
- pycopg/py.typed +0 -0
- pycopg/queries.py +262 -0
- pycopg/utils.py +133 -0
- pycopg-0.1.0.dist-info/METADATA +470 -0
- pycopg-0.1.0.dist-info/RECORD +15 -0
- pycopg-0.1.0.dist-info/WHEEL +4 -0
- pycopg-0.1.0.dist-info/licenses/LICENSE +21 -0
pycopg/__init__.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pycopg - High-level Python API for PostgreSQL/PostGIS/TimescaleDB.
|
|
3
|
+
|
|
4
|
+
Simple, powerful, pythonic database operations.
|
|
5
|
+
|
|
6
|
+
Example:
|
|
7
|
+
# Sync usage
|
|
8
|
+
from pycopg import Database
|
|
9
|
+
|
|
10
|
+
db = Database.from_env()
|
|
11
|
+
db.list_schemas()
|
|
12
|
+
db.list_tables("public")
|
|
13
|
+
|
|
14
|
+
# Async usage
|
|
15
|
+
from pycopg import AsyncDatabase
|
|
16
|
+
|
|
17
|
+
db = AsyncDatabase.from_env()
|
|
18
|
+
schemas = await db.list_schemas()
|
|
19
|
+
|
|
20
|
+
# Connection pooling
|
|
21
|
+
from pycopg import PooledDatabase, AsyncPooledDatabase
|
|
22
|
+
|
|
23
|
+
db = PooledDatabase.from_env(min_size=5, max_size=20)
|
|
24
|
+
with db.connection() as conn:
|
|
25
|
+
conn.execute("SELECT * FROM users")
|
|
26
|
+
|
|
27
|
+
# Migrations
|
|
28
|
+
from pycopg import Migrator
|
|
29
|
+
|
|
30
|
+
migrator = Migrator(db, "migrations/")
|
|
31
|
+
migrator.migrate()
|
|
32
|
+
|
|
33
|
+
# Roles & Permissions
|
|
34
|
+
db.create_role("appuser", password="secret", login=True)
|
|
35
|
+
db.grant("SELECT", "users", "appuser")
|
|
36
|
+
|
|
37
|
+
# Backup & Restore
|
|
38
|
+
db.pg_dump("backup.dump")
|
|
39
|
+
db.pg_restore("backup.dump")
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
from pycopg.database import Database
|
|
43
|
+
from pycopg.async_database import AsyncDatabase
|
|
44
|
+
from pycopg.config import Config
|
|
45
|
+
from pycopg.pool import PooledDatabase, AsyncPooledDatabase
|
|
46
|
+
from pycopg.migrations import Migrator
|
|
47
|
+
from pycopg.exceptions import (
|
|
48
|
+
PycopgError,
|
|
49
|
+
ConnectionError,
|
|
50
|
+
ConfigurationError,
|
|
51
|
+
ExtensionNotAvailable,
|
|
52
|
+
TableNotFound,
|
|
53
|
+
InvalidIdentifier,
|
|
54
|
+
MigrationError,
|
|
55
|
+
)
|
|
56
|
+
from pycopg.utils import (
|
|
57
|
+
validate_identifier,
|
|
58
|
+
validate_identifiers,
|
|
59
|
+
validate_interval,
|
|
60
|
+
validate_index_method,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
__version__ = "0.1.0"
|
|
64
|
+
__all__ = [
|
|
65
|
+
# Core
|
|
66
|
+
"Database",
|
|
67
|
+
"AsyncDatabase",
|
|
68
|
+
"Config",
|
|
69
|
+
# Pooling
|
|
70
|
+
"PooledDatabase",
|
|
71
|
+
"AsyncPooledDatabase",
|
|
72
|
+
# Migrations
|
|
73
|
+
"Migrator",
|
|
74
|
+
# Exceptions
|
|
75
|
+
"PycopgError",
|
|
76
|
+
"ConnectionError",
|
|
77
|
+
"ConfigurationError",
|
|
78
|
+
"ExtensionNotAvailable",
|
|
79
|
+
"TableNotFound",
|
|
80
|
+
"InvalidIdentifier",
|
|
81
|
+
"MigrationError",
|
|
82
|
+
# Utilities
|
|
83
|
+
"validate_identifier",
|
|
84
|
+
"validate_identifiers",
|
|
85
|
+
"validate_interval",
|
|
86
|
+
"validate_index_method",
|
|
87
|
+
# Metadata
|
|
88
|
+
"__version__",
|
|
89
|
+
]
|