Skip to content

Commit 20133df

Browse files
King-OzymandiasKing-Ozymandias
authored andcommitted
Basic support for SQLite(Sqlite3Cursor) => DataFrame
1 parent 0d4ff94 commit 20133df

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

src/BaselineOfDataFrame/BaselineOfDataFrame.class.st

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #BaselineOfDataFrame,
3-
#superclass : #BaselineOf,
4-
#category : #BaselineOfDataFrame
2+
#name : 'BaselineOfDataFrame',
3+
#superclass : 'BaselineOf',
4+
#category : 'BaselineOfDataFrame',
5+
#package : 'BaselineOfDataFrame'
56
}
67

7-
{ #category : #baselines }
8+
{ #category : 'baselines' }
89
BaselineOfDataFrame >> baseline: spec [
910
<baseline>
1011
spec for: #common do: [
@@ -18,13 +19,20 @@ BaselineOfDataFrame >> baseline: spec [
1819
spec
1920
baseline: 'AINormalization'
2021
with: [ spec repository: 'github://pharo-ai/normalization/src' ].
22+
spec
23+
baseline: 'SQLite3'
24+
with: [ spec repository: 'github://pharo-rdbms/Pharo-SQLite3/src' ].
2125

2226
"Packages"
2327
spec
2428
package: 'DataFrame' with: [ spec requires: #('AINormalization') ];
2529
package: 'DataFrame-Tests' with: [ spec requires: #('DataFrame') ];
2630
package: 'DataFrame-IO' with: [ spec requires: #('DataFrame' 'NeoCSV' 'NeoJSON') ];
31+
package: 'DataFrame-IO-Sqlite' with: [ spec requires: #('DataFrame' 'SQLite3') ];
2732
package: 'DataFrame-IO-Tests' with: [ spec requires: #('DataFrame-IO') ] ].
33+
34+
spec group: 'default' with: #('DataFrame-IO-Tests').
35+
spec group: 'sqlite' with: #('DataFrame-IO-Sqlite' 'DataFrame-IO-Tests').
2836

2937
spec
3038
for: #'pharo7.x'
@@ -37,5 +45,5 @@ BaselineOfDataFrame >> baseline: spec [
3745
do: [
3846
spec
3947
package: 'DataFrame-Pharo6';
40-
package: 'DataFrame-Pharo67' ]
48+
package: 'DataFrame-Pharo67' ]
4149
]

src/BaselineOfDataFrame/package.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Package { #name : #BaselineOfDataFrame }
1+
Package { #name : 'BaselineOfDataFrame' }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Extension { #name : 'DataFrame' }
2+
3+
{ #category : '*DataFrame-IO-Sqlite' }
4+
DataFrame class >> readFromSqliteCursor: aSqliteCursor [
5+
6+
| reader |
7+
reader := DataFrameSqliteReader new.
8+
^ self readFrom: aSqliteCursor using: reader
9+
]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Class {
2+
#name : 'DataFrameSqliteReader',
3+
#superclass : 'DataFrameReader',
4+
#category : 'DataFrame-IO-Sqlite',
5+
#package : 'DataFrame-IO-Sqlite'
6+
}
7+
8+
{ #category : 'reading' }
9+
DataFrameSqliteReader >> readFrom: aSqliteCursor [
10+
"Read all rows from cursor, stuff them into a new dataframe with columns of same name"
11+
12+
| cols |
13+
cols := aSqliteCursor columnNames. "need to grab columns before exhausting the cursor"
14+
^ DataFrame withRows: aSqliteCursor rows columnNames: cols
15+
]

src/DataFrame-IO-Sqlite/package.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Package { #name : 'DataFrame-IO-Sqlite' }

0 commit comments

Comments
 (0)