-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathupdate_db.ps1
More file actions
31 lines (26 loc) · 908 Bytes
/
Copy pathupdate_db.ps1
File metadata and controls
31 lines (26 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Powershell script for windows (not tested)
# Define all libraries as an array
$GPLMLIBS = @('ana', 'cap', 'con', 'cpd', 'dio', 'ics', 'ind', 'mpu', 'mcu', 'pwr', 'rfm', 'res', 'reg', 'xtr', 'osc', 'opt', 'art', 'swi')
# Path to the SQLite database file
$DBFILE = ".\database\parts.sqlite"
# Function to create the parts database
function Invoke-PartsDbCreate {
foreach ($lib in $GPLMLIBS) {
Write-Host "Processing library $lib..."
# Drop table if exists
sqlite3 $DBFILE "DROP TABLE IF EXISTS $lib"
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to drop table $lib"
exit 1
}
# Import CSV
sqlite3 -csv $DBFILE ".import .\database\g-$lib.csv $lib"
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to import CSV for $lib"
exit 1
}
}
exit 0
}
# Main script
Invoke-PartsDbCreate