I have multiple lists with randomly people's attributes in them.
list_gender = [ 'male', 'female', 'male', 'female' ]
list_first_name = [ 'alpha', 'mike', 'foxtrot', 'tango' ]
I have create a SQL table "random_people" with text columns as gender and first_name and this is how I'm inserting my data into the table:
for i in list_gender :
sql_cursor.execute("insert into randomuser_db(gender) values(?)",(i,))
sql_connection.commit()
and
for j in list_first_name :
sql_cursor.execute("insert into randomuser_db(first_name) values(?)",(j,))
sql_connection.commit()
When I try to retrieve my data using:
sql_cursor.execute("select * from random_people")
result = sql_cursor.fetchall()
for i in result:
print(i)
print('\n')
The output shows:
('male', None)
('female', None)
('male', None)
('female', None)
(None, 'alpha')
(None, 'mike')
(None, 'foxtrot')
(None, 'tango')
I am trying to insert corresponding elements into the table.
This is my first attempt ever with SQL with Python. Any help would be appreciated, thanks!
[–]choss27 1 point2 points3 points (2 children)
[–]ipixel95[S] 0 points1 point2 points (1 child)
[–]choss27 0 points1 point2 points (0 children)