-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from jpulidojr/sqlreader
Sqlreader implementation and remote http (requests) image viewer
- Loading branch information
Showing
15 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
Binary file added
BIN
+220 KB
data/wildfire/run_000baafc-fe1a-48a1-90c5-8edf2301ca8a_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+254 KB
data/wildfire/run_001a5aa3-1d00-473d-8e9c-56c6c217a025_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+146 KB
data/wildfire/run_001d82e8-6447-4218-8a82-e5d66b3ee965_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+149 KB
data/wildfire/run_0027a212-2e4c-40a6-830a-e14de1495b29_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+262 KB
data/wildfire/run_0027e586-0f94-4860-bf80-ca6b35c70155_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+227 KB
data/wildfire/run_0028f006-ff57-4d09-9282-d9bf0ab92f44_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+184 KB
data/wildfire/run_002b1a99-ab6d-4afe-93cf-77196379c3a0_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+223 KB
data/wildfire/run_004e4371-f3a9-42a3-9b0a-72299972116e_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+234 KB
data/wildfire/run_008452dd-b2df-4ad9-8509-da9a99167bb1_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+221 KB
data/wildfire/run_00998da4-889e-4e9f-a47b-685b961bb028_fuels-dens_2100_000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from pycinema import Filter | ||
|
||
import sqlite3 | ||
|
||
from os.path import exists | ||
import re | ||
|
||
class SqliteDatabaseReader(Filter): | ||
|
||
def __init__(self): | ||
super().__init__( | ||
inputs={ | ||
'path': '', | ||
'table': '', | ||
'file_column': 'FILE' | ||
}, | ||
outputs={ | ||
'table': [[]] | ||
} | ||
) | ||
|
||
def _update(self): | ||
|
||
table = [] | ||
dbPath = self.inputs.path.get() | ||
if not dbPath: | ||
self.outputs.table.set([[]]) | ||
return 0 | ||
|
||
if not exists(dbPath): | ||
print('[ERROR] sqlite db not found:', dbPath) | ||
self.outputs.table.set([[]]) | ||
return 0 | ||
|
||
tname = self.inputs.table.get() | ||
try: | ||
conn = sqlite3.connect(dbPath) | ||
cursor = conn.cursor() | ||
|
||
# capture the names of each column | ||
cdata = cursor.execute(f'PRAGMA table_info({tname});').fetchall() | ||
|
||
cnames = [entry[1] for entry in cdata] | ||
table.append(cnames) | ||
|
||
print(table) | ||
# capture row data | ||
data = cursor.execute("SELECT * FROM " + tname + "").fetchall() #LIMIT 10 | ||
for row in data: | ||
# tuple output convert to list | ||
table.append(list(row)) | ||
|
||
print(table) | ||
cursor.close() | ||
except sqlite3.Error as error: | ||
print("Error while connecting to sqlite", error) | ||
self.outputs.table.set([[]]) | ||
return 0 | ||
finally: | ||
if conn: | ||
conn.close() | ||
|
||
# remove empty lines | ||
table = list(filter(lambda row: len(row)>0, table)) | ||
|
||
# # force lower case header | ||
# table[0] = list(map(str.lower,table[0])) | ||
|
||
try: | ||
fileColumnIdx = [i for i, item in enumerate(table[0]) if re.search(self.inputs.file_column.get(), item, re.IGNORECASE)].pop() | ||
except: | ||
print('[ERROR] file column not found:',self.inputs.file_column.get()) | ||
self.outputs.table.set([[]]) | ||
return 0 | ||
|
||
for i in range(1,len(table)): | ||
table[i][fileColumnIdx] = table[i][fileColumnIdx] | ||
|
||
self.outputs.table.set(table) | ||
|
||
return 1 |
This file contains 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
This file contains 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