Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6777145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:06:46+00:00 2026-05-26T16:06:46+00:00

I need to store instances (or at least their state) in a database. The

  • 0

I need to store instances (or at least their state) in a database. The idea is that I should be able to re-create the instance on demand. Since I define the classes, I can choose how I would like to store the data.

Consider the following diagram, inheritance diagram:

                    A
                   / \
                  B   C
                 /\   /\
                D  E F  ...

The idea is that the instance can belong to any of those classes and can itself store other objects (that I have completely design control over).

My first thought is to store the state exclusively in a dictionary, dump the dictionary into a json and store it in the database. At run time, load json from the database convert it to dictionary, create an object passing in the dictionary that get’s setup and so on…

I’m not sure if that is a good approach, and also if there are any other issues that might crop up. I already came across one, where if you use myobj.dict you don’t actually get all the class’ parent’s attributes though…

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:06:47+00:00Added an answer on May 26, 2026 at 4:06 pm

    There are several approaches. I don’t really think we can tell you from the information you’ve provided what the best approach for you is.

    • You can use an ORM, like SQLAlchemy.
    • You can use an object database.
    • You could pickle your objects and store them in any relational database or datastore including shelve, which is included in the standard distribution.

    These are the approaches I can think of off the top of my head. Only you can determine which one(s) fit your requirements and intention best.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have id values for products that I need store. Right now they are
I need to store a series of configuration values in a database. A couple
I need to store a file, such that my ASP.Net MVC app can access
I need to store an encoding-state value on a video while it's been encoded
I need to store a special cookies that is coming from some non-django applications.
What is the best way to store instances of a class to file/database? We
I need to store several date values in a database field. These values will
I have a program that will store many instances of one class, let's say
I need to store various info about some movies, books, games, and maybe other
I need to store IP address in the most compact way possible, searching is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.