Size: 620
Comment:
|
Size: 938
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 7: | Line 7: |
{{{ sage: import sqlite3 }}} |
|
Line 10: | Line 13: |
This is a blank database at the moment | {{{ conn = sqlite3.connect("/full/path/mydata.db") }}} |
Line 12: | Line 17: |
This is a blank database at the moment. | |
Line 13: | Line 19: |
{{{ connection.execute }}} |
|
Line 16: | Line 27: |
This is our new entry in the database tempdb. |
{{{ E = EllipticCurve("389a") connection.execute("...") }}} This is our new entry in the database mydata! |
Line 24: | Line 38: |
will return the first one (fetchall will return all). | {{{ result = connection.execute("SELECT * FROM elliptic_curves WHERE rank = 2") result.fetchone() }} will return the first one (replacing "fetchone" by "fetchall" will return all). |
Tom Boothby's sqlite-tutorial
How to create a simple database in sqlite using SAGE.
In SAGE, type
sage: import sqlite3
To create a filename for the database
conn = sqlite3.connect("/full/path/mydata.db")
This is a blank database at the moment. Now create a table with fields labeled/typed as follows:
connection.execute
This creates a sqlite3.cursor object. Now let's enter an entry into this database
E = EllipticCurve("389a") connection.execute("...")
This is our new entry in the database mydata!
Suppose you entered something wrong and you want to delete an entry. You use the primary key to delete an entry:
To "query" all the elliptic curves of rank 2, type: