![]() ![]() Also, note that we are not needing to do a mit(). Finally, we can either just print the data, or iterate through it, like pasting the information. ![]() The select is like you highlighted, then you do c.fetchall(), so this is like you are copying your highlighted information. Think of this again, much like the computer cursor. Then, to access the data from the cursor, we use c.fetchall(). Notice that when we execute the query, we're executing it with the cursor as usual. Next, let's create another function, calling it read_from_db: def read_from_db(): Let's see what I mean:Ĭ.execute("CREATE TABLE IF NOT EXISTS stuffToPlot(unix REAL, datestamp TEXT, keyword TEXT, value REAL)")Ĭ.execute("INSERT INTO stuffToPlot VALUES(1452549219,' 13:53:39','Python',6)")ĭate = str((unix).strftime('%Y-%m-%d %H:%M:%S'))Ĭ.execute("INSERT INTO stuffToPlot (unix, datestamp, keyword, value) VALUES (?, ?, ?, ?)", While we can query the entire table, we can instead just query a single column, or even based on specific row values. Reading from a database is where the power of using something like SQLite over a flat file starts to make sense.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |