Skip to content

Commit 12e7dc3

Browse files
authored
Merge pull request #3 from efe-osa/develop
Add Database Via URL
2 parents d9cff51 + 6f90b1f commit 12e7dc3

16 files changed

Lines changed: 409 additions & 1842 deletions

File tree

.github/workflows/full-ci.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

client/src/App.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,29 @@ function App() {
3737
return data.response.trim();
3838
};
3939

40+
const openWindowPrompt = async () => {
41+
const url = prompt('Enter the URL of the database you want to add');
42+
const name = prompt('Enter the name of the database you want to add');
43+
if (url && name) {
44+
const data = await apiFetch('/sql/add-database', {
45+
method: 'POST',
46+
data: { databaseUrl: url, databaseName: name },
47+
});
48+
console.log(data);
49+
alert('Database added successfully');
50+
}
51+
};
52+
4053
return (
4154
<main className={styles.main}>
4255
<img src={sqlLogo} className={styles.icon}></img>
43-
<h3 className={styles.heading}>SQL Assistant</h3>
56+
<h3 className={styles.heading}>
57+
SQL Assistant
58+
</h3>
59+
<small>Current Database: cars.db</small>
60+
<button onClick={openWindowPrompt} className={styles.btnText} type="submit" name="add-database" value="Add Database">
61+
Add Database using URL
62+
</button>
4463
<form className={styles.form} onSubmit={onSubmit}>
4564
<input
4665
type="text"

client/src/styles/index.module.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@
8989
cursor: pointer;
9090
}
9191

92+
.main .btnText:hover {
93+
background: none;
94+
transform: translateY(1px);
95+
}
96+
.main .btnText {
97+
padding: .5rem 0;
98+
color: var(--color-primary);
99+
margin-bottom: 1.5rem;
100+
background: none;
101+
border: none;
102+
font-size: .75rem;
103+
border-radius: 4px;
104+
transition: transform 0.1s all ease-in-out;
105+
text-align: center;
106+
width: 100%;
107+
cursor: pointer;
108+
}
109+
92110
.main .btnGroup {
93111
display: flex;
94112
gap: 10px;

server/db/car_db.sqlite

Whitespace-only changes.

server/docker-compose.yml

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,39 @@ services:
1414
dockerfile: ./Dockerfile
1515
ports:
1616
- "3001:3001"
17-
env_file:
18-
- .env.local
17+
environment:
18+
- TOGETHER_API_KEY=${TOGETHER_API_KEY}
19+
- TOGETHER_MODEL=${TOGETHER_MODEL}
20+
- TOGETHERAI_API_KEY=${TOGETHERAI_API_KEY}
21+
- TOGETHERAI_MODEL_NAME=${TOGETHERAI_MODEL_NAME}
22+
- LANGCHAIN_TRACING_V2=${LANGCHAIN_TRACING_V2}
23+
- LANGCHAIN_CALLBACKS_BACKGROUND=${LANGCHAIN_CALLBACKS_BACKGROUND}
24+
- LANGSMITH_ENDPOINT=${LANGSMITH_ENDPOINT}
25+
- LANGSMITH_API_KEY=${LANGSMITH_API_KEY}
26+
- LANGSMITH_PROJECT=${LANGSMITH_PROJECT}
27+
- SQLITE_DB_PATH=${SQLITE_DB_PATH}
28+
- DB_DIR=${DB_DIR}
29+
1930
depends_on:
2031
sqlite:
2132
condition: service_healthy
2233
networks:
2334
- sql-assistant-network
2435

2536
sqlite:
26-
image: nouchka/sqlite3:latest
37+
image: keinos/sqlite3:latest
2738
container_name: sqlite-db
2839
ports:
29-
- "8080:8080"
40+
- "5432:5432"
3041
volumes:
31-
- ./sqlite_data/init-cars-db.sh:/db/init-cars-db.sh
3242
- ./sqlite_data/car_db.sql:/db/car_db.sql
33-
- sqlite_data:/db
43+
- ./sqlite_data:/db
3444
entrypoint: >
35-
sh -c "sqlite3 cars.db < /db/car_db.sql && tail -f /dev/null"
45+
sh -c "sqlite3 /db/cars.db << /db/car_db.sql && tail -f /dev/null"
3646
healthcheck:
3747
test: ["CMD", "sqlite3", "/db/cars.db", ".tables"]
3848
interval: 5s
3949
timeout: 5s
4050
retries: 5
4151
networks:
4252
- sql-assistant-network
43-
44-
sqlitebrowser:
45-
image: lscr.io/linuxserver/sqlitebrowser:latest
46-
container_name: sqlitebrowser
47-
environment:
48-
- PUID=1000
49-
- PGID=1000
50-
- TZ=Etc/UTC
51-
- CUSTOM_HTTP_PORT=4000
52-
- CUSTOM_HTTPS_PORT=4001
53-
depends_on:
54-
sqlite:
55-
condition: service_healthy
56-
security_opt:
57-
- seccomp:unconfined #optional
58-
volumes:
59-
- sqlite_data:/db/cars.db
60-
ports:
61-
- 4000:4000
62-
- 4001:4001
63-
restart: unless-stopped
64-
networks:
65-
- sql-assistant-network

server/env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ SQLITE_DB_PATH=./data/car_database.sqlite
2020
RATE_LIMIT_WINDOW_MS=900000
2121
RATE_LIMIT_MAX_REQUESTS=100
2222

23+
# Database Directory
24+
DB_DIR=./db
25+

0 commit comments

Comments
 (0)