I
I
Ilya2015-08-10 10:20:03
Python
Ilya, 2015-08-10 10:20:03

Why, when writing data to a cell, does it treat this data as a column name?

sqlite3.OperationalError: no such column: 9500.
That is, the variable str(result2).replace('\'','') is treated as a column name. And not as data to be written.

for item in result23:
        cur.executescript("""INSERT INTO result ('#','number','target_1', 'target_2','bet_size','payot')
                        VALUES (
                        """+str(count_for)+""","""+item+""","""+str(result2).replace('\'','')+""","""+str(result3)+""","""+str(result4)+""","""+str(result5)+""");""")
        count_for += 1

result2 type
12898e69d29f4408a74316f379673b4c.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Movchan, 2015-08-10
@Alexander1705

First, what type is result23? And what is result2?
Second, don't allow more than 80 characters per line. This is very inconvenient to read.
Thirdly:

for count, item in enumerate(result23):
   ...

Something like that:
for count, item in enumerate(result23):
    cur.executescript(
        """INSERT INTO result """
        """('#','number','target_1', 'target_2','bet_size','payot') """
        """VALUES (""" + 
        ",".join((str(count), item, str(result2).replace('\'',''),
                 str(result3), str(result4), str(result5))) +
        ");"
    )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question