@@ -46,8 +46,8 @@ Create an SQLAlchemy :doc:`Session <sa:orm/session_basics>`:
46
46
>>> Base = declarative_base()
47
47
48
48
49
- Connection string
50
- =================
49
+ Connect
50
+ =======
51
51
52
52
In SQLAlchemy, a connection is established using the ``create_engine `` function.
53
53
This function takes a connection string, actually an `URL `_, that varies from
@@ -65,7 +65,9 @@ to a different server the following syntax can be used:
65
65
>>> sa.create_engine(' crate://otherserver:4200' )
66
66
Engine(crate://otherserver:4200)
67
67
68
- Since CrateDB is a clustered database running on multiple servers, it is
68
+ Multiple Hosts
69
+ --------------
70
+ Because CrateDB is a clustered database running on multiple servers, it is
69
71
recommended to connect to all of them. This enables the DB-API layer to
70
72
use round-robin to distribute the load and skip a server if it becomes
71
73
unavailable. In order to make the driver aware of multiple servers, use
@@ -76,6 +78,8 @@ the ``connect_args`` parameter like so:
76
78
... })
77
79
Engine(crate://)
78
80
81
+ TLS Options
82
+ -----------
79
83
As defined in :ref: `https_connection `, the client validates SSL server
80
84
certificates by default. To configure this further, use e.g. the ``ca_cert ``
81
85
attribute within the ``connect_args ``, like:
@@ -96,6 +100,37 @@ In order to disable SSL verification, use ``verify_ssl_cert = False``, like:
96
100
... ' verify_ssl_cert' : False ,
97
101
... })
98
102
103
+ Timeout Options
104
+ ---------------
105
+ In order to configure TCP timeout options, use the ``timeout `` parameter within
106
+ ``connect_args ``,
107
+
108
+ >>> timeout_engine = sa.create_engine(' crate://localhost/' , connect_args = {' timeout' : 42.42 })
109
+ >>> timeout_engine.raw_connection().driver_connection.client._pool_kw[" timeout" ]
110
+ 42.42
111
+
112
+ or use the ``timeout `` URL parameter within the database connection URL.
113
+
114
+ >>> timeout_engine = sa.create_engine(' crate://localhost/?timeout=42.42' )
115
+ >>> timeout_engine.raw_connection().driver_connection.client._pool_kw[" timeout" ]
116
+ 42.42
117
+
118
+ Pool Size
119
+ ---------
120
+
121
+ In order to configure the database connection pool size, use the ``pool_size ``
122
+ parameter within ``connect_args ``,
123
+
124
+ >>> timeout_engine = sa.create_engine(' crate://localhost/' , connect_args = {' pool_size' : 20 })
125
+ >>> timeout_engine.raw_connection().driver_connection.client._pool_kw[" maxsize" ]
126
+ 20
127
+
128
+ or use the ``pool_size `` URL parameter within the database connection URL.
129
+
130
+ >>> timeout_engine = sa.create_engine(' crate://localhost/?pool_size=20' )
131
+ >>> timeout_engine.raw_connection().driver_connection.client._pool_kw[" maxsize" ]
132
+ 20
133
+
99
134
100
135
Basic DDL operations
101
136
====================
0 commit comments