You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+87Lines changed: 87 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,82 @@ with engine.connect() as conn:
42
42
43
43
```
44
44
45
+
## Authentication
46
+
47
+
To specify credentials, you should pass `credentials` object to `connect_args` argument of `create_engine` method.
48
+
49
+
### Static Credentials
50
+
51
+
To use static credentials you should specify `username` and `password` as follows:
52
+
53
+
```python3
54
+
engine = sa.create_engine(
55
+
"yql+ydb://localhost:2136/local",
56
+
connect_args= {
57
+
"credentials": {
58
+
"username": "...",
59
+
"password": "..."
60
+
}
61
+
}
62
+
)
63
+
```
64
+
65
+
### Token Credentials
66
+
67
+
To use access token credentials you should specify `token` as follows:
68
+
69
+
```python3
70
+
engine = sa.create_engine(
71
+
"yql+ydb://localhost:2136/local",
72
+
connect_args= {
73
+
"credentials": {
74
+
"token": "..."
75
+
}
76
+
}
77
+
)
78
+
```
79
+
80
+
### Service Account Credentials
81
+
82
+
To use service account credentials you should specify `service_account_json` as follows:
83
+
84
+
```python3
85
+
engine = sa.create_engine(
86
+
"yql+ydb://localhost:2136/local",
87
+
connect_args= {
88
+
"credentials": {
89
+
"service_account_json": {
90
+
"id": "...",
91
+
"service_account_id": "...",
92
+
"created_at": "...",
93
+
"key_algorithm": "...",
94
+
"public_key": "...",
95
+
"private_key": "..."
96
+
}
97
+
}
98
+
}
99
+
)
100
+
```
101
+
102
+
### Credentials from YDB SDK
103
+
104
+
To use any credentials that comes with `ydb` package, just pass credentials object as follows:
105
+
106
+
```python3
107
+
import ydb.iam
108
+
109
+
engine = sa.create_engine(
110
+
"yql+ydb://localhost:2136/local",
111
+
connect_args= {
112
+
"credentials": ydb.iam.MetadataUrlCredentials()
113
+
}
114
+
)
115
+
116
+
```
117
+
118
+
119
+
## Migrations
120
+
45
121
To setup `alembic` to work with `YDB` please check [this example](https://github.com/ydb-platform/ydb-sqlalchemy/tree/main/examples/alembic).
46
122
47
123
## Development
@@ -82,3 +158,14 @@ $ source venv/bin/activate
82
158
$ pip install -r requirements.txt
83
159
$ python examples/example.py
84
160
```
161
+
162
+
## Additional Notes
163
+
164
+
### Pandas
165
+
It is possible to use YDB SA engine with `pandas` fuctions [to_sql()](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_sql.html) and [read_sql](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_sql.html). However, there are some limitations:
166
+
167
+
*`to_sql` method can not be used with column tables, since it is impossible to specify `NOT NULL` columns with current `to_sql` arguments. YDB requires column tables to have `NOT NULL` attribute on `PK` columns.
168
+
169
+
*`to_sql` is not fully optimized to load huge datasets. It is recommended to use `method="multi"` and avoid setting a very large `chunksize`.
170
+
171
+
*`read_sql` is not fully optimized to load huge datasets and could lead to significant memory consumptions.
0 commit comments