Skip to content

Commit

Permalink
Merge pull request #272 from tablelandnetwork/dtb/bulk-import
Browse files Browse the repository at this point in the history
Bulk table import
  • Loading branch information
dtbuchholz authored May 29, 2024
2 parents 30bba70 + 8767691 commit 766fde5
Show file tree
Hide file tree
Showing 14 changed files with 532 additions and 88 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ name: Review

on:
push:
branches: ["main", "staging"]
branches: ["main"]
pull_request:
branches: ["main", "staging"]

env:
STORE_PRIVATE_KEY: ${{ secrets.STORE_PRIVATE_KEY }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ name: Test

on:
push:
branches: ["main", "staging"]
branches: ["main"]
pull_request:
branches: ["main", "staging"]

env:
# This is local hardhat account #7 key.
Expand Down
95 changes: 95 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"prettier-plugin-tailwindcss": "^0.5.3",
"sinon": "^15.0.1",
"tailwindcss": "^3.4.3",
"tempy": "^3.1.0",
"ts-node": "^10.9.1",
"tsx": "^4.10.5",
"typescript": "^5.4.5"
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@tableland/sdk": "^7.0.0",
"@tableland/sqlparser": "^1.3.0",
"@tableland/studio-client": "0.0.1",
"@tableland/studio-validators": "^0.0.1",
"chalk": "^5.3.0",
"cli-select-2": "^2.0.0",
"cosmiconfig": "^8.0.0",
Expand Down
27 changes: 1 addition & 26 deletions packages/cli/src/commands/import-data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { readFileSync } from "fs";
import type { Arguments } from "yargs";
import { parse } from "csv-parse";
import chalk from "chalk";
import { type Wallet } from "ethers";
import { studioAliases } from "@tableland/studio-client";
Expand All @@ -12,6 +11,7 @@ import {
helpers,
logger,
normalizePrivateKey,
parseCsvFile,
FileStore,
} from "../utils.js";

Expand Down Expand Up @@ -102,31 +102,6 @@ export const handler = async (
}
};

const parseCsvFile = async function (file: string): Promise<string[][]> {
return await new Promise(function (resolve, reject) {
const parser = parse();
const rows: any[] = [];

parser.on("readable", function () {
let row;
while ((row = parser.read()) !== null) {
rows.push(row);
}
});

parser.on("error", function (err) {
reject(err);
});

parser.on("end", function () {
resolve(rows);
});

parser.write(file);
parser.end();
});
};

async function confirmImport(info: {
statements: string[];
rowCount: number;
Expand Down
Loading

1 comment on commit 766fde5

@vercel
Copy link

@vercel vercel bot commented on 766fde5 May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.