How to view exact storage capacity of Replit.db in python?

How do we view the exact amount of storage in the replit.db that has been used?
I am creating a user database which has a n number of keys. I need to find out how many profiles i can make with the free 50 MiB i get in replit db.

There is a limit of 5,000 keys on ReplitDB, so to find out how many free keys you have left, you can use this code: 5000 - len(db)

1 Like

Or, @level9neil , the Replit DB tool tab shows how many keys there are, and you can subtract that from 5000.
However, not all keys is 1kb. They vary depending on the size of each key.
Hope this helps!

2 Likes

how much storage would this take roughly?

db['accounts'][userid] = {
			'time':{
				'tz':""
			},
			'profile':{
				'f_name':str(self.first_name),
				'l_name':str(self.last_name),
				'user_avatar':str(interaction.user.avatar),
				'name':f"{str(self.first_name)} {str(self.last_name)}",
				'discord_name':str(interaction.user.name),
				'inbox':{
				    'info':{
					    'username':str(self.username),
					    'id':{'name':str(self.emailid),'domain':str(self.emaildomain)},
					    'password':str(self.password)
				    },
				    'sent':[],
				    'recieved':[{
					    'from':"The Bot",
					    'from_id':1173531949202161685,
					    'title':"Welcome to the Mailing System!",
					    'body':f"This is the default message that is stored into your account.\n\nWe have support for newlines,\nTabs\t!\t!!!,\n**BOLD**, _Italics_, __Underlines__, ~~STRIKETHROUGHS~~, <Code blocks;>, and lastly, ||SECRETS🤫||",
					    'important':True,
					    'sent_at_relative':int(dt.timestamp()),
					    'sent_at':str(dt.format('dddd DD MMMM YYYY')),
					    'view_once':False,
					    'anonymous':False
				    }],
				    'spam':[],
				    'blocked':{
					    'mails':[],
					    'accounts':[]
				    }
			    },
				'cosmetics':{
					'avatar':"https://i.pinimg.com/originals/5b/e4/88/5be488211f49fa95d0079f8b6706d144.jpg",
					'about':{
						'unlocked':False,
						'about':" "
					},
					'banner':{
						'unlocked':False,
						'banner_url':""
					},
					'embed_color':0x2b2d31,
					'embed_color_str':"2b2d31"
				}
			},
			'economy':{
				'pocket':{
					'money':{
						'max_limit':100,
						'amount':100
					},
					'items':{
					  	'max_items_limit':25,
					  	'items_list':[]
				  	}
				},
				'wallet':{
					'money':{
						'max_limit':10_000,
						'amount':10_000
					},
					'cards':{
						'max_card_limit':5,
						'card_list':[]
					},
				},
				'bank_account':{
					'opened':False,
					'bank_chosen':False,
					'bank_choice':"",
					'transactions':{
						'deposits':[],
						'withdrawals':[]
					},
					'money':{
						'amount':0
					}
				},
				'backpack':{
					'bought':False,
					'inv_slots':25,
					'inv_slot_max_capacity':250_000,
					'inv_slot_capacity_upgrade':4_500,
					'inventory':[]
				}
			},
			'stats':{
				'created_at':{
					'raw':str(pendulum.now()),
					'format_long':str(pendulum.now(tz="UTC").format('dddd, Do MMMM, YYYY, hh:mm A (zz)'))
				},
				'total_money':{
					'bank_included':False,
					'total':10_100
				},
				'names_log':[
					{
						'time_applied':str(pendulum.now(tz="UTC")),
						'f_name':str(self.first_name),
						'l_name':str(self.last_name),
						'current':True,
						'time_removed':""
					}
				]
			}
		}

would the total keys in this be equivalent to the number of sub-keys in this, or is there something else to it?

I did this and it partially worked.
I saw the amount of keys update,
but I didn’t see the storage indicator go up, it was just stuck at 0/50 MiB. Even when i was at 120 keys in the database, it was stuck at 0.

Try closing and reopening the Database tab. If nothing changes, then your database is still too small for its storage to be displayed.

1 Like