Skip to content

Instantly share code, notes, and snippets.

@derrickturk
Created September 3, 2015 18:24
Show Gist options
  • Save derrickturk/bd98ce8e1e5431ea0323 to your computer and use it in GitHub Desktop.
Save derrickturk/bd98ce8e1e5431ea0323 to your computer and use it in GitHub Desktop.
Access SQLite db in Spotfire IronPython. Would literally murder for with blocks.
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()
@Fortuneod
Copy link

Thanks a million. This helped a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment