Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania
Viewing all articles
Browse latest Browse all 65225

Python-Sqlite3 problem z insertem do bazy danych

$
0
0

Mam kod 

#!/usr/bin/python3

import sqlite3 as sq
import pandas as pd

connection = sq.connect('stocks.db')

cur = connection.cursor()
cur.execute('''CREATE TABLE stocks
            (data text, open numeric, high numeric, low numeric, close numeric, volume numeric, adj_close numeric)''')

purchases = pd.read_csv("../new.csv")

cur.executemany('INSERT INTO stocks VALUES (?,?,?,?,?,?,?)',purchases)
connection.commit()

for row in cur.execute("SELECT * FROM stocks"):
    print(row,'\n')

A dane z new.csv tak

Date,Open,High,Low,Close,Volume,Adj Close
2010-01-04,68.720001,69.260002,68.190002,69.150002,27809100,57.203028
2010-01-05,69.190002,69.449997,68.800003,69.419998,30174700,57.426378
2010-01-06,69.449997,70.599998,69.339996,70.019997,35044700,57.922715
2010-01-07,69.900002,70.059998,69.419998,69.800003,27192100,57.74073

No i nie działa mi insert. Wypisuje mi błąd 

sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 7, and there are 4 supplied.

 


Viewing all articles
Browse latest Browse all 65225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>