Autosave: 2024-06-23 19:15:05
This commit is contained in:
parent
bcad37e625
commit
0831697099
7 changed files with 94 additions and 147 deletions
BIN
.zk/notebook.db
BIN
.zk/notebook.db
Binary file not shown.
|
@ -1,72 +0,0 @@
|
|||
---
|
||||
id: l045
|
||||
title: DynamoDB CLI commands
|
||||
tags: [AWS, databases, dynamodb]
|
||||
created: Saturday, June 22, 2024
|
||||
---
|
||||
|
||||
# DynamoDB CLI commands
|
||||
|
||||
## Connecting to a local (Docker)/prod (AWS) DynamoDB instance
|
||||
|
||||
In order to distinguish between local and production accounts you should keep
|
||||
seperate profiles for each (via `.aws/config` and `.aws/credentials`).
|
||||
|
||||
When connecting to a local DB use the local profile and the local URL. Without
|
||||
the `--profile` flag, AWS will default to the `default` profile which will
|
||||
typically be your credentials for accessing AWS on the remote.
|
||||
|
||||
It also sometimes required to add the endpoint-url when working locally:
|
||||
|
||||
```
|
||||
--endpoint-url http://localhost:800
|
||||
|
||||
> When using the commans below locally, assume `--endpoint-url` and `--profile`
|
||||
> have been appended
|
||||
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
aws dynamodb list-tables \
|
||||
--profile timetracking_dev \
|
||||
--endpoint-url http://localhost:800
|
||||
```
|
||||
|
||||
## Delete a table
|
||||
|
||||
```sh
|
||||
aws dynamodb delete-table \
|
||||
--table-name TableName
|
||||
```
|
||||
|
||||
## Create table from JSON schema
|
||||
|
||||
```sh
|
||||
aws dynamodb create-table \
|
||||
--cli-input-json file://create-timeentries-table.json \
|
||||
|
||||
```
|
||||
|
||||
## Describe the table
|
||||
|
||||
View the table schema:
|
||||
|
||||
```sh
|
||||
|
||||
aws dynamodb describe-table \
|
||||
--table-name TimeEntries
|
||||
```
|
||||
|
||||
## Scan the table
|
||||
|
||||
```sh
|
||||
aws dynamodb scan \
|
||||
--table-name TimeEntries \
|
||||
--output table
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Related notes
|
|
@ -1,64 +0,0 @@
|
|||
---
|
||||
id: 8b6h
|
||||
title: DynamoDB SDK commands
|
||||
tags: [AWS, databases, dynamodb]
|
||||
created: Sunday, June 23, 2024
|
||||
---
|
||||
|
||||
# DynamoDB SDK commands
|
||||
|
||||
The following commands are for using `@aws-sdk/client-dynamodb` (the JS SDK).
|
||||
|
||||
## Create client
|
||||
|
||||
```js
|
||||
import DynamoDBClient from "@aws-sdk/client-dynamodb";
|
||||
|
||||
const client = new DynamoDBClient({
|
||||
region: "eu-west-2",
|
||||
accessKeyId: process.env.ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.ACCESS_KEY_ID,
|
||||
});
|
||||
```
|
||||
|
||||
### DynamoDB Document Client
|
||||
|
||||
The Document Client returns the data as a standard JSON document in the manner
|
||||
of a document-based NoSQL database. Without it, DynamoDB will return the data
|
||||
with type data which is unwieldy and hard to parse.
|
||||
|
||||
To transform into a document structure:
|
||||
|
||||
```js
|
||||
import DynamoDBClient from "@aws-sdk/client-dynamodb";
|
||||
import DynamoDBDocumentClient from "@aws-sdk/lib-dynamodb";
|
||||
|
||||
const client = new DynamoDBClient({
|
||||
region: "eu-west-2",
|
||||
accessKeyId: process.env.ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.ACCESS_KEY_ID,
|
||||
});
|
||||
|
||||
const dynamoDbDocumentClient = DynamoDBDocumentClient.from(client);
|
||||
```
|
||||
|
||||
## Query a table
|
||||
|
||||
Querying is the most performant and cost-effective method since it is an O(1)
|
||||
lookup against a partition key or secondary index.
|
||||
|
||||
```js
|
||||
const params = {
|
||||
TableName: "YourTableName",
|
||||
KeyConditionExpression: "#pk = :pk",
|
||||
ExpressionAttributeNames: { "#pk": "PrimaryKeyAttributeName" },
|
||||
ExpressionAttributeValues: { ":pk": "PrimaryKeyValue" },
|
||||
};
|
||||
```
|
||||
|
||||
## Scan a table
|
||||
|
||||
Scanning is less performant (O(n)) and most expensive since it requires checking
|
||||
every item in the database.
|
||||
|
||||
## Related notes
|
|
@ -16,6 +16,16 @@ When connecting to a local DB use the local profile and the local URL. Without
|
|||
the `--profile` flag, AWS will default to the `default` profile which will
|
||||
typically be your credentials for accessing AWS on the remote.
|
||||
|
||||
It also sometimes required to add the endpoint-url when working locally:
|
||||
|
||||
```
|
||||
--endpoint-url http://localhost:800
|
||||
|
||||
> When using the commans below locally, assume `--endpoint-url` and `--profile`
|
||||
> have been appended
|
||||
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
|
@ -28,8 +38,6 @@ aws dynamodb list-tables \
|
|||
|
||||
```sh
|
||||
aws dynamodb delete-table \
|
||||
--profile timetracking_dev \
|
||||
--endpoint-url http://localhost:8000 \
|
||||
--table-name TableName
|
||||
```
|
||||
|
||||
|
@ -38,9 +46,25 @@ aws dynamodb delete-table \
|
|||
```sh
|
||||
aws dynamodb create-table \
|
||||
--cli-input-json file://create-timeentries-table.json \
|
||||
--profile timetracking_dev \
|
||||
--endpoint-url http://localhost:8000
|
||||
|
||||
```
|
||||
|
||||
## Describe the table
|
||||
|
||||
View the table schema:
|
||||
|
||||
```sh
|
||||
|
||||
aws dynamodb describe-table \
|
||||
--table-name TimeEntries
|
||||
```
|
||||
|
||||
## Scan the table
|
||||
|
||||
```sh
|
||||
aws dynamodb scan \
|
||||
--table-name TimeEntries \
|
||||
--output table
|
||||
```
|
||||
|
||||
## Related notes
|
||||
|
|
|
@ -7,16 +7,75 @@ created: Sunday, June 23, 2024
|
|||
|
||||
# DynamoDB SDK commands
|
||||
|
||||
The following commands are for using `$aws-sdk/client-dynamodb` (the JS SDK).
|
||||
The following commands are for using `@aws-sdk/client-dynamodb` (the JS SDK).
|
||||
|
||||
## Create client
|
||||
|
||||
```js
|
||||
const params = {
|
||||
import DynamoDBClient from "@aws-sdk/client-dynamodb";
|
||||
|
||||
const client = new DynamoDBClient({
|
||||
region: "eu-west-2",
|
||||
accessKeyId: process.env.ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.ACCESS_KEY_ID,
|
||||
});
|
||||
```
|
||||
|
||||
### DynamoDB Document Client
|
||||
|
||||
The Document Client returns the data as a standard JSON document in the manner
|
||||
of a document-based NoSQL database. Without it, DynamoDB will return the data
|
||||
with type data which is unwieldy and hard to parse.
|
||||
|
||||
To transform into a document structure:
|
||||
|
||||
```js
|
||||
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
||||
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
|
||||
|
||||
const client = new DynamoDBClient({
|
||||
region: "eu-west-2",
|
||||
accessKeyId: process.env.ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.ACCESS_KEY_ID,
|
||||
});
|
||||
|
||||
const dynamoDbDocumentClient = DynamoDBDocumentClient.from(client);
|
||||
```
|
||||
|
||||
## Query a table
|
||||
|
||||
Querying is the most performant and cost-effective method since it is an O(1)
|
||||
lookup against a partition key or secondary index.
|
||||
|
||||
```js
|
||||
import { DynamoDBDocumentClient, QueryCommand } from "@aws-sdk/lib-dynamodb";
|
||||
|
||||
const params = {
|
||||
TableName: "YourTableName",
|
||||
KeyConditionExpression: "#pk = :pk",
|
||||
ExpressionAttributeNames: { "#pk": "PrimaryKeyAttributeName" },
|
||||
ExpressionAttributeValues: { ":pk": "PrimaryKeyValue" },
|
||||
};
|
||||
|
||||
const dynamoDbDocumentClient = DynamoDBDocumentClient.from(client);
|
||||
const data = await dynamoDbDocumentClient.send(new QueryCommand(params));
|
||||
console.log(data);
|
||||
```
|
||||
|
||||
## Scan a table
|
||||
|
||||
Scanning is less performant (O(n)) and most expensive since it requires checking
|
||||
every item in the database.
|
||||
|
||||
```js
|
||||
import { DynamoDBDocumentClient, ScanCommand } from "@aws-sdk/lib-dynamodb";
|
||||
|
||||
const params = {
|
||||
TableName: "YourTableName",
|
||||
};
|
||||
|
||||
const dynamoDbDocumentClient = DynamoDBDocumentClient.from(client);
|
||||
const data = await dynamoDbDocumentClient.send(new ScanCommand(params));
|
||||
```
|
||||
|
||||
## Related notes
|
||||
|
|
|
@ -7,8 +7,7 @@ tags:
|
|||
# Integrated circuits
|
||||
|
||||
An integrated circuit (IC) is a single unit that comprises several logic gates
|
||||
designed for the easy construction of
|
||||
[digital circuits](Digital_circuits.md).
|
||||
designed for the easy construction of [digital circuits](Digital_circuits.md).
|
||||
The terms "integrated circuit" and "chip" are often used interchangeably.
|
||||
|
||||
An IC puts the gates on a single piece of silicon that has electrical contact
|
||||
|
@ -24,5 +23,6 @@ to a breadboard.
|
|||
|
||||
_An integrated circuit and its use on a breadboard:_
|
||||
|
||||
<img align="left" width="200" src="/home/thomas/repos/computer_science/img/integrated-circuit.jpeg">
|
||||
<img width="200" src="/home/thomas/repos/computer_science/img/breadboard-DIP.jpg">
|
||||

|
||||
|
||||

|
||||
|
|
|
@ -21,5 +21,5 @@ generic diode circuit symbol:
|
|||
An LED diode lights up when the right amount of current flows through it. A
|
||||
standard LED has a maximum current of 20mA. An appropriate
|
||||
[resistor](Resistance.md#resistors)
|
||||
must therefore be added to the circuit to ensure the current doesn't exeedd this
|
||||
must therefore be added to the circuit to ensure the current doesn't exceed this
|
||||
amount.
|
||||
|
|
Loading…
Add table
Reference in a new issue