@@ -46,8 +46,8 @@ Create an SQLAlchemy :doc:`Session <sa:orm/session_basics>`:
4646 >>> Base = declarative_base()
4747
4848
49- Connection string
50- =================
49+ Connect
50+ =======
5151
5252In SQLAlchemy, a connection is established using the ``create_engine `` function.
5353This 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:
6565 >>> sa.create_engine(' crate://otherserver:4200' )
6666 Engine(crate://otherserver:4200)
6767
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
6971recommended to connect to all of them. This enables the DB-API layer to
7072use round-robin to distribute the load and skip a server if it becomes
7173unavailable. In order to make the driver aware of multiple servers, use
@@ -76,6 +78,8 @@ the ``connect_args`` parameter like so:
7678 ... })
7779 Engine(crate://)
7880
81+ TLS Options
82+ -----------
7983As defined in :ref: `https_connection `, the client validates SSL server
8084certificates by default. To configure this further, use e.g. the ``ca_cert ``
8185attribute within the ``connect_args ``, like:
@@ -96,6 +100,37 @@ In order to disable SSL verification, use ``verify_ssl_cert = False``, like:
96100 ... ' verify_ssl_cert' : False ,
97101 ... })
98102
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+
99134
100135Basic DDL operations
101136====================
0 commit comments