Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM dart:3.7.2
FROM dart:3.10.2

RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
Expand Down Expand Up @@ -27,5 +27,14 @@ ENV PATH="/root/.cargo/bin:${PATH}"

WORKDIR /app

COPY pubspec.yaml pubspec.lock ./
COPY third_party/sqlite3.dart/sqlite3 ./third_party/sqlite3.dart/sqlite3

RUN dart pub get

RUN dart --disable-analytics

RUN dart run build_runner build --delete-conflicting-outputs

ENTRYPOINT [ "/bin/zsh" ]
CMD ["-l"]
CMD ["-l"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ Place it in a standard library path (e.g., `/usr/lib`, or use `/usr/local/lib/`)
## 🚀 Usage

Use **any standard SQLite library** in your language/runtime — this project handles the dynamic strategy and connection logic under the hood.

---

## 🧪 How to test

See the dedicated guide: [`README_TESTING.md`](README_TESTING.md).
38 changes: 38 additions & 0 deletions README_TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# How To Test

Follow these steps from the project root.

## 1. Pull the submodule dependencies

`pubspec.yaml` uses a local path override from the `third_party/sqlite3.dart` submodule, so initialize and update submodules first.

```bash
git submodule update --init --recursive third_party/sqlite3.dart
```

## 2. Build the Docker image

```bash
docker build -t libturso:sandbox .
```

## 3. Run the container with the current directory mounted

```bash
docker run --rm -it \
-v "$(pwd):/app" \
-w /app \
libturso:sandbox
```

## 4. Compile the binary inside the container

```bash
cargo build
```

## 5. Run the Dart file in `bin/` to test

```bash
dart run bin/libsqlite3_turso.dart
```
44 changes: 22 additions & 22 deletions bin/libsqlite3_turso.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ void main() async {

final database = AppDatabase();

await database.transaction(() async {
// Create the table if it doesn't exist
final result = await database.into(database.todoItems).insert(
TodoItemsCompanion.insert(
title: 'todo: setup drift',
content: 'We need to set up drift for our SQLite database.',
),
);

await (database
.update(database.todoItems)
..where((tbl) => tbl.id.equals(result)))
.write(TodoItemsCompanion(content: const Value('Updated content')));


print('Inserted item with ID: $result');
});

// final allItems = await database.select(database.todoItems).get();
// for (final item in allItems) {
// print('Item: ${item.title}, Content: ${item.content}');
// }
// await database.transaction(() async {
// // Create the table if it doesn't exist
// final result = await database.into(database.todoItems).insert(
// TodoItemsCompanion.insert(
// title: 'todo: setup drift',
// content: 'We need to set up drift for our SQLite database.',
// ),
// );

// await (database
// .update(database.todoItems)
// ..where((tbl) => tbl.id.equals(result)))
// .write(TodoItemsCompanion(content: const Value('Updated content')));


// print('Inserted item with ID: $result');
// });

final allItems = await database.select(database.todoItems).get();
for (final item in allItems) {
print('Item: ${item.title}, Content: ${item.content}');
}

// final server = await HttpServer.bind(InternetAddress.anyIPv4, 8081);

Expand Down
Loading