Nov-04-2021, 12:23 PM
Hi, I want to store the users I created in the file named "asdsad". The first information is being processed correctly, but the second information is overwritten by the first information. I don't want this. I want the "json" data to be written at the bottom. Where am I making a mistake?
AccInformation.json
Mycode :
AccInformation.json
{
"67368262694": {
"T.C": "32424324",
"Adı": "Super",
"Soyadı": "UZUN",
"E-Posta": "[email protected]",
"Kullanıcı Adı": "jgkSUperstar",
"Şifresi": "123456",
"Kullanıcı Anahtarı": "KDW6-T7L1-EPMB-H92Y-AS0O-VNZ4",
"Kayıt Tarihi": "04/Kasim/2021 - Saat : 15:14"
}
}The next data needs to come under the above data. Example :{
"67368262694": {
"T.C": "32424324",
"Adı": "Super",
"Soyadı": "UZUN",
"E-Posta": "[email protected]",
"Kullanıcı Adı": "jgkSUperstar",
"Şifresi": "123456",
"Kullanıcı Anahtarı": "KDW6-T7L1-EPMB-H92Y-AS0O-VNZ4",
"Kayıt Tarihi": "04/Kasim/2021 - Saat : 15:14"
},
"12457262694": {
"T.C": "75424323",
"Adı": "aaaaaa",
"Soyadı": "KISA",
"E-Posta": "[email protected]",
"Kullanıcı Adı": "Harveyspecter",
"Şifresi": "123456",
"Kullanıcı Anahtarı": "CDW6-T7L1-EPMB-H92Y-AS0O-VNZ4",
"Kayıt Tarihi": "04/Kasim/2021 - Saat : 15:14"
}
}I have changed my codes many times, but I have not been able to overcome this problem..Mycode :
import sqlite3 as sqlite
import Generator
import datetime
import locale
import GeneralSecure
import os
import json
import time
locale.setlocale(locale.LC_ALL, '')
# Account Management
class Account:
def __init__(self, user_id, TCKN, firstName, lastName,
email, username, password, accountKEY, register_date):
#, Get & Set
self.user_id = user_id
self.TCKN = TCKN
self.firstName = firstName
self.lastName = lastName
self.email = email
self.username = username
self.password = password
self.accountKEY = accountKEY
self.register_date = register_date
class AccountManagement:
def __init__(self):
self.PendingUsers = {}
def CreateAccount(self, user_id, TCKN, firstName, lastName,
email, username, password, accountKEY, register_date, filename='AccInformation.json'):
gay = datetime.datetime.now() # gay = gün / ay / yıl / saat
register_date = datetime.datetime.strftime(gay, '%d/%B/%Y - Saat : %H:%M')
igenerator = Generator.Production()
user_id = igenerator.id_generator()
accountKEY = igenerator.license_generator()
self.PendingUsers.update({
user_id:{
"T.C": TCKN,
"Adı": firstName,
"Soyadı": lastName,
"E-Posta": email,
"Kullanıcı Adı": username,
"Şifresi": password,
"Kullanıcı Anahtarı": accountKEY,
"Kayıt Tarihi": register_date
}
})
self.WriteFile(self.PendingUsers)
def WriteFile(self, user, filename='AccInformation.json'):
with open(filename, "r+", encoding='utf-8') as json_write:
json.dump(user, json_write, indent=1, ensure_ascii=False)
register = AccountManagement()
register.CreateAccount("128", "32424324", "eeeee", "UZUN", "[email protected]", "test", "123456", "1", "1")
