Created
September 3, 2015 18:24
-
-
Save derrickturk/bd98ce8e1e5431ea0323 to your computer and use it in GitHub Desktop.
Access SQLite db in Spotfire IronPython. Would literally murder for with blocks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clr | |
clr.AddReferenceToFileAndPath(r'X:\path\to\System.Data.SQLite.dll') | |
import System.Data.SQLite as sql | |
try: | |
db = sql.SQLiteConnection(r'DataSource=X:\path\to\Chinook_Sqlite.sqlite;Version=3') | |
db.Open() | |
command = sql.SQLiteCommand('select * from Artist', db) | |
try: | |
reader = command.ExecuteReader() | |
try: | |
while reader.Read(): | |
print reader['Name'] | |
finally: | |
reader.Dispose() | |
finally: | |
command.Dispose() | |
db.Close() | |
finally: | |
db.Dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a million. This helped a lot