4.4 SQL Statements Used to Insert the data - data population
###user
user_table = table('user',
column('Id', sa.VARCHAR(20)),
column('create_at', sa.DATE),
column('password', sa.VARCHAR(20)),
column('authority', sa.Enum("Admin", "Developer", "Member", name = "authority")),
column('name', sa.VARCHAR(30)),
column('phone', sa.VARCHAR(20)),
column('email', sa.VARCHAR(100)),
column('member_balance', sa.Integer)
)
op.bulk_insert(
user_table,
[
{'Id':'1', 'create_at':date(2013, 9, 17), 'password':'123456', 'authority':'Admin', 'name':'Jonathan Joestar', 'phone':'555-0123', 'email':'123@email.com', 'member_balance':100000},
{'Id':'2', 'create_at':date(2014, 11, 29), 'password':'222222', 'authority':'Developer', 'name':'Diamond planet', 'phone':'555-6666', 'email':'DiamondPlanet@email.com', 'member_balance':1000},
{'Id':'3', 'create_at':date(2015, 6, 24), 'password':'333333', 'authority':'Member', 'name':'Dio Brando', 'phone':'555-0000', 'email':'wryyy@email.com', 'member_balance':999999},
{'Id':'4', 'create_at':date(2019, 7, 5), 'password':'444444', 'authority':'Member', 'name':'Giorno Giovanna', 'phone':'555-9999', 'email':'Muda@email.com','member_balance': 0},
{'Id':'5', 'create_at':date(2020, 9, 28), 'password':'555555', 'authority':'Developer', 'name':'Hamiyo', 'phone':'555-8964', 'email':'Hamiyo@email.com', 'member_balance':5000},
{'Id':'6', 'create_at':date(2022, 11, 4), 'password':'666666', 'authority':'Developer', 'name':'Shift Up', 'phone':'555-1122', 'email':'ShiftUp@email.com', 'member_balance':9487},
]
)
###game
game_table = table('game',
column('game_id', sa.VARCHAR(20)),
column('create_at', sa.DATE),
column('game_name', sa.VARCHAR(20)),
column('game_sale_price', sa.Integer),
column('game_developer', sa.VARCHAR(20)),
column('game_picture', sa.BLOB),
column('game_introduction', sa.VARCHAR(2000)),
column('game_discount', sa.DECIMAL),
column('game_genre', sa.VARCHAR(50)),
column('game_version', sa.VARCHAR(20)),
column('game_developer_id', sa.VARCHAR(20))
)
op.bulk_insert(
game_table,
[
{'game_id':'1', 'create_at':date(2013, 9, 17), 'game_name':'GTA W', 'game_sale_price':1299, 'game_developer':'Diamond planet', 'game_picture':'C://Users//User//Desktop//1.jpg'.encode(), 'game_introduction':'A game just like real life','game_discount':0.9, 'game_genre':'Action', 'game_version':'11.1.3', 'game_developer_id':2},
{'game_id':'2', 'create_at':date(2020, 9, 28), 'game_name':'Alternative Demon', 'game_sale_price':120, 'game_developer':'Hamiyo', 'game_picture':'C://Users//User//Desktop//1.jpg'.encode(), 'game_introduction':'This game definitely not copy other game', 'game_discount':1, 'game_genre':'Adventure', 'game_version':'5.7.9', 'game_developer_id':5},
{'game_id':'3', 'create_at':date(2022, 11, 4), 'game_name':'Kinne', 'game_sale_price':10, 'game_developer':'Shift Up', 'game_picture':'C://Users//User//Desktop//1.jpg'.encode(), 'game_introduction':'A typical gun game', 'game_discount':0.5, 'game_genre':'Gun', 'game_version':'1.10.5', 'game_developer_id':6},
]
)
###cart
cart_table = table('cart',
column('cart_id', sa.VARCHAR(20)),
column('user_id', sa.VARCHAR(20)),
column('game_id', sa.VARCHAR(20)),
column('cost', sa.Integer),
column('place_order', sa.Boolean)
)
op.bulk_insert(
cart_table,
[
{'cart_id':'1', 'user_id':'1', 'game_id':'1', 'cost':1299, 'place_order':True},
{'cart_id':'2', 'user_id':'2', 'game_id':'2', 'cost':120, 'place_order':True},
{'cart_id':'3', 'user_id':'4', 'game_id':'3', 'cost':10, 'place_order':True},
]
)
###game_list
game_list_table = table('game_list',
column('game_list_id', sa.VARCHAR(20)),
column('create_at', sa.DATE),
column('user_id', sa.VARCHAR(20)),
column('game_list_type', sa.Enum("Wishlist", "Library", name = "game_list_type")),
column('comment', sa.VARCHAR(200)),
column('category', sa.VARCHAR(100)),
column('game_id', sa.VARCHAR(20)),
)
op.bulk_insert(
game_list_table,
[
{'game_list_id':'1', 'create_at':date(2020,10,10), 'user_id':'3', 'game_list_type':'Wishlist', 'comment':None, 'category':'Relaxing', 'game_id':'1'},
{'game_list_id':'2', 'create_at':date(2022,11,20), 'user_id':'3', 'game_list_type':'Library', 'comment':'This game has too much bug', 'category':'Relaxing', 'game_id':'3'},
{'game_list_id':'3', 'create_at':date(2021,5,13), 'user_id':'4', 'game_list_type':'Library', 'comment':'Yes definetely a original game', 'category':'Relaxing', 'game_id':'2'},
]
)
###issue
issue_table = table('issue',
column('issue_id', sa.VARCHAR(20)),
column('create_at', sa.DATE),
column('issue_type', sa.Enum("Violation", "Refund", name = "issue_type")),
column('issue_deleted_at', sa.DATE),
column('user_id', sa.VARCHAR(20)),
column('violation_content', sa.VARCHAR(200)),
column('refund_acception', sa.Boolean),
column('refund_gameId', sa.VARCHAR(20)),
)
op.bulk_insert(
issue_table,
[
{'issue_id':'1', 'create_at':date(2022,11,10), 'issue_type':'Violation', 'issue_deleted_at':None, 'user_id':'3','violation_content':'hacking', 'refund_acception':None, 'refund_gameId':'1'},
{'issue_id':'2', 'create_at':date(2022,11,15), 'issue_type':'Refund', 'issue_deleted_at':date(2022,11,16), 'user_id':'4', 'violation_content':None, 'refund_acception':None, 'refund_gameId':'2'},
]
)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
SQL
'''
INSERT INTO user (Id,create_at,password,authority,name,Phone,email,member_balance)
VALUES
('1', '2013-09-17', '123456', 'Admin', 'Jonathan Joestar', '555-0123', '123@email.com', 100000),
('2', '2014-11-29', '222222', 'Developer', 'Diamond planet', '555-6666', 'DiamondPlanet@email.com', 1000),
('3', '2015-06-24', '333333', 'Member', 'Dio Brando', '555-0000', 'wryyy@email.com', 999999),
('4', '2019-07-05', '444444', 'Member', 'Giorno Giovanna', '555-9999', 'Muda@email.com', 0),
('5', '2020-09-28', '555555', 'Developer', 'Hamiyo', '555-8964', 'Hamiyo@email.com', 5000),
('6', '2022-11-04', '666666', 'Developer', 'Shift Up', '555-1122', 'ShiftUp@email.com', 9487);
INSERT INTO game (game_id,create_at,game_name,game_sale_price,game_developer,game_picture,game_introduction,game_genre,game_version,game_developer_id)
VALUES
('1', '2013-09-17', 'GTA W', 1299, 'Diamond planet', '/storage/game_pic/1/GTAW.jpg', 'A game just like real life', 0.9, 'Action', '11.1.3', 2),
('2', '2020-09-28', 'Alternative Demon', 120, 'Hamiyo', '/storage/game_pic/2/AlternativeDemon.jpg', 'This game definitely not copy other game', 1, 'Adventure', '5.7.9', 5),
('3', '2022-11-04', 'Kinne', 10, 'Shift Up', '/storage/game_pic/3/Kinne.jpg', 'A typical gun game', 0.5, 'Gun', '1.10.5', 6);
INSERT INTO cart (cart_id,user_id,game_id,cost,place_order)
VALUES
('1', '1', '1', 1299, TRUE),
('2', '2', '2', 120, TRUE),
('3', '4', '3', 10, TRUE);
INSERT INTO game_list (game_list_id, create_at, user_id, game_list_type, comment, category,game_id)
VALUES
('1', '2020-10-10', '3', 'Wishlist', NULL, 'Relaxing', '1'),
('2', '2022-11-20', '3', 'Library', 'This game has too much bug', 'Relaxing', '3'),
('3', '2021-05-13', '4', 'Library', 'Yes definetely a original game', 'Relaxing', '2');
INSERT INTO issue (issue_id, create_at, game_list_type, issue_deleted_at, user_id, violation_content, refund_acception, refund_gameId)
VALUES
('1', '2022-11-10', 'Violation', NULL, '3', 'hacking', NULL, '1'),
('2', '2022-11-15', 'Refund', '2022-11-16', '4', NULL, TRUE, '2');
'''
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →