|
9 | 9 | #include "duckdb_python/pystatement.hpp" |
10 | 10 | #include "duckdb_python/pyrelation.hpp" |
11 | 11 | #include "duckdb_python/expression/pyexpression.hpp" |
12 | | -#include "duckdb_python/pyresult.hpp" |
13 | 12 | #include "duckdb_python/pybind11/exceptions.hpp" |
14 | 13 | #include "duckdb_python/typing.hpp" |
15 | 14 | #include "duckdb_python/functional.hpp" |
@@ -923,7 +922,31 @@ static void InitializeConnectionMethods(py::module_ &m) { |
923 | 922 | return conn->GetRowcount(); |
924 | 923 | }, |
925 | 924 | "Get result set row count", py::kw_only(), py::arg("connection") = py::none()); |
926 | | -} // END_OF_CONNECTION_METHODS |
| 925 | + |
| 926 | + // END_OF_CONNECTION_METHODS |
| 927 | + |
| 928 | + // We define these "wrapper" methods manually because they are overloaded to return relations |
| 929 | + m.def( |
| 930 | + "arrow", |
| 931 | + [](py::object &arrow_object, shared_ptr<DuckDBPyConnection> conn) -> unique_ptr<DuckDBPyRelation> { |
| 932 | + if (!conn) { |
| 933 | + conn = DuckDBPyConnection::DefaultConnection(); |
| 934 | + } |
| 935 | + return conn->FromArrow(arrow_object); |
| 936 | + }, |
| 937 | + "Create a relation object from an Arrow object", py::arg("arrow_object"), py::kw_only(), |
| 938 | + py::arg("connection") = py::none()); |
| 939 | + m.def( |
| 940 | + "df", |
| 941 | + [](const PandasDataFrame &value, shared_ptr<DuckDBPyConnection> conn) -> unique_ptr<DuckDBPyRelation> { |
| 942 | + if (!conn) { |
| 943 | + conn = DuckDBPyConnection::DefaultConnection(); |
| 944 | + } |
| 945 | + return conn->FromDF(value); |
| 946 | + }, |
| 947 | + "Create a relation object from the DataFrame df", py::arg("df"), py::kw_only(), |
| 948 | + py::arg("connection") = py::none()); |
| 949 | +} |
927 | 950 |
|
928 | 951 | PYBIND11_MODULE(DUCKDB_PYTHON_LIB_NAME, m) { // NOLINT |
929 | 952 | py::enum_<duckdb::ExplainType>(m, "ExplainType", |
|
0 commit comments