grantjay
grantjay

Reputation: 138

Accessing a database with a different programming language

I built an app in Django, and have a script I wrote in Java that I'd like to use on the data from the Postgres database.

I understand I can simply run a raw SQL query with the data in Java, but would it be more efficient to create ORM models with Java to access and process the data?

More generally, if I mainly use a database with one framework, but need to access the data with another language or outside of the framework, should I build models with an ORM or use raw SQL?

Upvotes: 0

Views: 103

Answers (1)

michaeldel
michaeldel

Reputation: 2385

That is up to you, there is no one-size-fits-all solution for this. Because you cannot directly work with the whole Django framework you will have to create and maintain the database interface in your other language.

but need to access the data with another language or outside of the framework

Depending on the proportion of data you need to access, you may consider creating and communicating with an API instead, for instance using Django REST Framework. If your Django app is, and will remain the core of what works with the data in this database, this is probably the most sensible way to deal with interfacing to that data from other languages and environments.

Upvotes: 1

Related Questions