nautilus_infrastructure/python/sql/pg.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use pyo3::prelude::*;
17
18use crate::sql::pg::PostgresConnectOptions;
19
20#[pymethods]
21#[pyo3_stub_gen::derive::gen_stub_pymethods(module = "nautilus_trader.infrastructure")]
22impl PostgresConnectOptions {
23 /// Creates a new `PostgresConnectOptions` instance.
24 #[new]
25 #[pyo3(signature = (host, port, user, password, database))]
26 const fn py_new(
27 host: String,
28 port: u16,
29 user: String,
30 password: String,
31 database: String,
32 ) -> Self {
33 Self::new(host, port, user, password, database)
34 }
35
36 /// Returns a string representation of the configuration.
37 fn __repr__(&self) -> String {
38 format!(
39 "PostgresConnectOptions(host={}, port={}, username={}, database={})",
40 self.host, self.port, self.username, self.database
41 )
42 }
43
44 /// Returns the host.
45 #[getter]
46 fn host(&self) -> String {
47 self.host.clone()
48 }
49
50 /// Returns the port.
51 #[getter]
52 const fn port(&self) -> u16 {
53 self.port
54 }
55
56 /// Returns the username.
57 #[getter]
58 fn username(&self) -> String {
59 self.username.clone()
60 }
61
62 /// Returns the password.
63 #[getter]
64 fn password(&self) -> String {
65 self.password.clone()
66 }
67
68 /// Returns the database.
69 #[getter]
70 fn database(&self) -> String {
71 self.database.clone()
72 }
73}