-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathveritabanı.txt
46 lines (25 loc) · 1008 Bytes
/
veritabanı.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Terminalde, eski SQLite dosyasını silin
rm ./instance/anime_site.db
Daha sonra, Flask shell veya bir Python betiği ile veritabanını yeniden oluşturabilirsiniz.
from app import db # Veritabanı nesnesini içe aktarın
db.create_all() # Tüm tabloları oluşturun
Flash shell ile database ekleme yap
from app import db, User
from werkzeug.security import generate_password_hash
# Kullanıcı bilgileri
username = "admin"
password = "adminpsw"
can_delete = True
can_edit = True
can_add_user = True
# Şifreyi hash'le
hashed_password = generate_password_hash(password, method='pbkdf2:sha256')
# Yeni kullanıcıyı oluştur
new_user = User(username=username, password=hashed_password, can_delete=can_delete, can_edit=can_edit, can_add_user=can_add_user)
# Veritabanına ekle ve işlemi kaydet
db.session.add(new_user)
db.session.commit()
print("Kullanıcı başarıyla eklendi!")
Migrate için komutlar.
flask db migrate -m "Make user_id nullable in Log model"
flask db upgrade