backstop 0.1.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.
- backstop-0.1.0/PKG-INFO +34 -0
- backstop-0.1.0/README.md +11 -0
- backstop-0.1.0/backstop/__init__.py +47 -0
- backstop-0.1.0/backstop/cli.py +931 -0
- backstop-0.1.0/backstop/guard.py +311 -0
- backstop-0.1.0/backstop/logger.py +103 -0
- backstop-0.1.0/backstop/metadata.py +110 -0
- backstop-0.1.0/backstop/native.py +423 -0
- backstop-0.1.0/backstop/parser.py +358 -0
- backstop-0.1.0/backstop/restore.py +384 -0
- backstop-0.1.0/backstop/snapshot.py +645 -0
- backstop-0.1.0/backstop/sqlalchemy.py +85 -0
- backstop-0.1.0/backstop.egg-info/PKG-INFO +34 -0
- backstop-0.1.0/backstop.egg-info/SOURCES.txt +25 -0
- backstop-0.1.0/backstop.egg-info/dependency_links.txt +1 -0
- backstop-0.1.0/backstop.egg-info/entry_points.txt +2 -0
- backstop-0.1.0/backstop.egg-info/requires.txt +14 -0
- backstop-0.1.0/backstop.egg-info/top_level.txt +1 -0
- backstop-0.1.0/pyproject.toml +46 -0
- backstop-0.1.0/setup.cfg +4 -0
- backstop-0.1.0/tests/test_cli_launch.py +102 -0
- backstop-0.1.0/tests/test_full_loop.py +386 -0
- backstop-0.1.0/tests/test_manifest_contract.py +67 -0
- backstop-0.1.0/tests/test_native_backup.py +172 -0
- backstop-0.1.0/tests/test_parser.py +216 -0
- backstop-0.1.0/tests/test_restore.py +411 -0
- backstop-0.1.0/tests/test_snapshot.py +193 -0
backstop-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: backstop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Production-grade database safety platform — intercept, snapshot, recover
|
|
5
|
+
Project-URL: Homepage, https://github.com/pratyush2514/Backstop
|
|
6
|
+
Project-URL: Repository, https://github.com/pratyush2514/Backstop.git
|
|
7
|
+
Project-URL: Issues, https://github.com/pratyush2514/Backstop/issues
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: sqlglot>=23.0.0
|
|
11
|
+
Requires-Dist: psycopg2-binary>=2.9.0
|
|
12
|
+
Requires-Dist: pyarrow>=14.0.0
|
|
13
|
+
Requires-Dist: boto3>=1.34.0
|
|
14
|
+
Requires-Dist: click>=8.1.0
|
|
15
|
+
Requires-Dist: rich>=13.0.0
|
|
16
|
+
Requires-Dist: pydantic>=2.0.0
|
|
17
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
18
|
+
Requires-Dist: structlog>=24.0.0
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
21
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
22
|
+
Requires-Dist: moto[s3]>=5.0.0; extra == "dev"
|
|
23
|
+
|
|
24
|
+
# Backstop Python Package
|
|
25
|
+
|
|
26
|
+
Backstop provides:
|
|
27
|
+
|
|
28
|
+
- the `backstop` CLI for restore, doctor, drill, backup, PITR, and WAL workflows;
|
|
29
|
+
- a Python SDK for guarded `psycopg2` and SQLAlchemy usage;
|
|
30
|
+
- local-first PostgreSQL safety tooling that works with S3-compatible storage.
|
|
31
|
+
|
|
32
|
+
Project home:
|
|
33
|
+
|
|
34
|
+
- https://github.com/pratyush2514/Backstop
|
backstop-0.1.0/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Backstop Python Package
|
|
2
|
+
|
|
3
|
+
Backstop provides:
|
|
4
|
+
|
|
5
|
+
- the `backstop` CLI for restore, doctor, drill, backup, PITR, and WAL workflows;
|
|
6
|
+
- a Python SDK for guarded `psycopg2` and SQLAlchemy usage;
|
|
7
|
+
- local-first PostgreSQL safety tooling that works with S3-compatible storage.
|
|
8
|
+
|
|
9
|
+
Project home:
|
|
10
|
+
|
|
11
|
+
- https://github.com/pratyush2514/Backstop
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""backstop — production-grade database safety platform.
|
|
2
|
+
|
|
3
|
+
Public API
|
|
4
|
+
----------
|
|
5
|
+
guard(conn, storage, actor, mode) → GuardedConnection
|
|
6
|
+
Wrap a psycopg2 connection with backstop protection.
|
|
7
|
+
|
|
8
|
+
protect_engine(engine, storage, actor, mode)
|
|
9
|
+
Attach backstop protection to a SQLAlchemy Engine.
|
|
10
|
+
|
|
11
|
+
RiskLevel
|
|
12
|
+
Enum of risk classifications: SAFE, LOW, HIGH, CRITICAL.
|
|
13
|
+
|
|
14
|
+
RiskResult
|
|
15
|
+
Dataclass describing the result of a SQL risk assessment.
|
|
16
|
+
|
|
17
|
+
Example usage::
|
|
18
|
+
|
|
19
|
+
import psycopg2
|
|
20
|
+
import backstop
|
|
21
|
+
|
|
22
|
+
raw_conn = psycopg2.connect(DATABASE_URL)
|
|
23
|
+
db = backstop.guard(
|
|
24
|
+
conn=raw_conn,
|
|
25
|
+
storage="s3://my-bucket@http://localhost:9000",
|
|
26
|
+
actor="gpt-agent-prod",
|
|
27
|
+
mode="protect",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# All SQL executed through db.execute() is now intercepted and protected.
|
|
31
|
+
db.execute("DROP TABLE users") # Snapshots users → S3, then drops the table
|
|
32
|
+
db.commit()
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from .guard import GuardedConnection, GuardedCursor, guard
|
|
36
|
+
from .parser import RiskLevel, RiskResult
|
|
37
|
+
from .sqlalchemy import protect_engine
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"guard",
|
|
41
|
+
"GuardedConnection",
|
|
42
|
+
"GuardedCursor",
|
|
43
|
+
"protect_engine",
|
|
44
|
+
"RiskLevel",
|
|
45
|
+
"RiskResult",
|
|
46
|
+
]
|
|
47
|
+
|