T
T
tixonochek2021-02-22 11:18:52
Python
tixonochek, 2021-02-22 11:18:52

SQLite3 - Why is the table not displayed?

See my code:

import sqlite3
import time
import random
 
conn = sqlite3.connect("db.db") # или :memory: чтобы сохранить в RAM
cursor = conn.cursor()
 
# Создание таблицы
cursor.execute("""CREATE TABLE IF not exists player(
        name text,
        id text,
        race text
               )""")
conn.commit()

def playerData(returning="n"):
  if returning == "n":
    eName = input("name, please - ")
    eId = str((random.randint(1000000000000, 100000000000000000000)))
    eRace = input("race, please - ")
  
    playerData = [(eName, eId, eRace), ("Georgy", "001", "Orc")] # тут я перепробовал триллион возможных вариантов скобок и их расположения..
  
    cursor.executemany("INSERT INTO player VALUES (?,?,?)", playerData)
    conn.commit()

  elif returning == "y":
    eName = input("name, please - ")
    eId = str((random.randint(1000000000000, 100000000000000000000)))
    eRace = input("race, please - ")
  
    playerData = [(eName, eId, eRace), ("Georgy", "001", "Orc")] # тут я перепробовал триллион возможных вариантов скобок и их расположения..
  
    cursor.executemany("INSERT INTO player VALUES (?,?,?)", playerData)
    conn.commit()
    return print(cursor.fetchall())

playerData("y")

And why does it return empty []? Not a table? How to get it out? I'm just new to SQLite.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2021-02-22
@idShura

INSERT This is inserting a record into the table, you need SELECT * FROM ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question