Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
¿Cómo almacenar una matriz de dictados de Python en PostgreSQL?

Tengo un proyecto Django y tal matriz en él:

 {(0,0):{'a':True,'b':False ... },(0,1):{'a':True,'b':True ... },(1,1):{'a':True,'b':False ... }... }

Necesito almacenar esta matriz en la base de datos PostgreSQL. Pensé que ArrayField podría ayudar, pero no tengo idea de cómo declarar dicha matriz. He leído https://docs.djangoproject.com/en/1.8/ref/contrib/postgres/fields/
pero no era mi situación. ¿Podría mostrarme un ejemplo?

Estoy usando Django 1.8

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

El campo JSON debería ser perfecto para usted. https://docs.djangoproject.com/en/dev/ref/contrib/postgres/fields/#querying-jsonfield

 from django.contrib.postgres.fields import JSONField from django.db import models class ModelName(models.Model): json_data = JSONField()

Ahora para guardar los datos,

 ModelName.objects.create(json_data={(0,0):{'a':True,'b':False ... },(0,1):{'a':True,'b':True ... },(1,1):{'a':True,'b':False ... }... })
over 4 years ago · Santiago Trujillo Report

0

PostgreSQL tiene dos tipos que quizás desee consultar,

  • jsonb
  • hstore

Ambos tienen funcionalidad superpuesta. Sin embargo, JSON es parte de la especificación SQL 2016; hstore mientras tiene algunas ventajas en JSONB es una cosa de PostgreSQL

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!