1

Resolved

create record problem

description

Hi - I am running windows 7 64, powershell 64 bit using psqlite v1.0
I can successfully load the module and create a table, but create a record fails. Below is a listing of what happens:


Import-Module sqlite
New-PSDrive -Name db -psp SQLite

cmdlet New-PSDrive at command pipeline position 1
Supply values for the following parameters:
Root:

Name Used (GB) Free (GB) Provider Root

db SQLite [data source=:memory:]


New-Item db:/MyTable -filename text


PSPath : SQLite::[data source=:memory:]\MyTable
PSParentPath : SQLite::[data source=:memory:]
PSChildName : MyTable
PSDrive : db
PSProvider : SQLite
PSIsContainer : True


Get-ChildItem db:


PSPath : SQLite::[data source=:memory:]\MyTable
PSParentPath : SQLite::[data source=:memory:]
PSChildName : MyTable
PSDrive : db
PSProvider : SQLite
PSIsContainer : True
SSItemMode : d+~<
TABLE_CATALOG : main
TABLE_SCHEMA :
TABLE_NAME : MyTable
TABLE_TYPE : table
TABLE_ID : 1
TABLE_ROOTPAGE : 2
TABLE_DEFINITION : CREATE TABLE MyTable ( filename text )
RowError :
RowState : Unchanged
Table : {MyTable}
ItemArray : {main, , MyTable, table...}
HasErrors : False

New-Item -Path db:/MyTable -filename test
New-Item : Sequence contains no elements
At line:1 char:9
  • New-Item <<<< -Path db:/MyTable -filename test
    • CategoryInfo : NotSpecified: ([data source=:memory:]\MyTable:String) [New-Item], InvalidOperationException
    • FullyQualifiedErrorId : NewItem.Invoke,Microsoft.PowerShell.Commands.NewItemCommand
New-Item -Path db:/MyTable -filename "test"
New-Item : Sequence contains no elements
At line:1 char:9
  • New-Item <<<< -Path db:/MyTable -filename "test"
    • CategoryInfo : NotSpecified: ([data source=:memory:]\MyTable:String) [New-Item], InvalidOperationException
    • FullyQualifiedErrorId : NewItem.Invoke,Microsoft.PowerShell.Commands.NewItemCommand
New-Item -Path db:/MyTable -Value @{filename="test"}
New-Item : Sequence contains no elements
At line:1 char:9
  • New-Item <<<< -Path db:/MyTable -Value @{filename="test"}
    • CategoryInfo : NotSpecified: ([data source=:memory:]\MyTable:String) [New-Item], InvalidOperationException
    • FullyQualifiedErrorId : NewItem.Invoke,Microsoft.PowerShell.Commands.NewItemCommand
TABLE_CATALOG : main
TABLE_SCHEMA :
TABLE_NAME : MyTable
TABLE_TYPE : table
TABLE_ID : 1
TABLE_ROOTPAGE : 2
TABLE_DEFINITION : CREATE TABLE MyTable ( filename text )


I have been using the sqlite ado.net 2.0/3.5 version 1.065.0 successfully on my machine. Are there any conflicts between that and the your sqlite powershell provider.

TIA

Nat Davis

comments

beefarino wrote Feb 10, 2012 at 8:48 PM

Hi Nat;

Try adding a primary key column to your table spec. The provider needs an identity column to be able to "address" each record consistently. My apologies - this isn't clear at all from the docs; come to think of it, the provider should add a primary key column if the table spec doesn't include one.... (opening issue now).

Jim

beefarino wrote Jun 25, 2012 at 6:32 PM

added automagic primary key feature in 1.1