# What is the currently recommended way to access a postgres database?

**URL:** <https://discourse.julialang.org/t/what-is-the-currently-recommended-way-to-access-a-postgres-database/75862>\
**Category:** Data\
**Tags:** data, postgresql, sql, database\
**Created:** [February 5, 2022, 3:45pm UTC](https://discourse.julialang.org/t/what-is-the-currently-recommended-way-to-access-a-postgres-database/75862 "2022-02-05T15:45:39Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ImreSamu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/imresamu/32/20677_2.png) [@ImreSamu](https://discourse.julialang.org/u/ImreSamu)\
**Post date:** [February 5, 2022, 4:14pm UTC](https://discourse.julialang.org/t/what-is-the-currently-recommended-way-to-access-a-postgres-database/75862/3 "2022-02-05T16:14:14Z")

</div>

> [@met-j](#):
>
> Is there something else I should look at?

- The [`LibPQ.jl`](https://github.com/invenia/LibPQ.jl) is the preferred.
  - Alternative: [ODBC.jl](https://github.com/JuliaDatabases/ODBC.jl/blob/main/docs/src/index.md)

- Future: PL/Julia ( [pljulia / pljulia · GitLab](https://gitlab.com/pljulia/pljulia) ) as moving the “julia” code to the server side;  
( disclaimer: I am a committer )  
IMHO: now it is usable, but still in ~developer only status.  
it was a [GSOC 2021 project: 🐘 Create procedural language extension for the Julia :julia: programming language](https://discourse.julialang.org/t/gsoc-2021-postgresql-create-procedural-language-extension-for-the-julia-programming-language/56918)

#### pljulia example ( from the readme ):

```sql
CREATE FUNCTION julia_setof_int()
RETURNS SETOF INTEGER AS $$
    for i in 1:5
        return_next(i)
    end
$$ LANGUAGE pljulia;

SELECT julia_setof_int();
 julia_setof_int 
-----------------
               1
               2
               3
               4
               5
(5 rows)

CREATE FUNCTION julia_setof_array()
RETURNS SETOF INTEGER[] AS $$
x =[[1,2], [3,4]]
for i in x
    return_next(i)
end
$$ LANGUAGE pljulia;

SELECT julia_setof_array();
 julia_setof_array 
-------------------
 {1,2}
 {3,4}
(2 rows)

```

---

_[View the full topic](https://discourse.julialang.org/t/what-is-the-currently-recommended-way-to-access-a-postgres-database/75862)._
