Skip to content
Open
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ uv run sfa_meta_prompt_openai_v1.py \
--variables "user-prompt"
```

Python Code to SQLite Agent:

```bash
uv run sfa_sqlite_add_code.py -d ./data/analytics.db -p ./path/to/python/files
```

## Features

Expand Down Expand Up @@ -183,6 +187,17 @@ uv run sfa_meta_prompt_openai_v1.py \
uv run sfa_meta_prompt_openai_v1.py
```

### Python Code to SQLite Agent
> (sfa_sqlite_add_code.py)

An AI-powered assistant that adds Python code to a SQLite database table.

Example usage:
```bash
# Add Python code to the SQLite database
uv run sfa_sqlite_add_code.py -d ./data/analytics.db -p ./path/to/python/files
```

### Git Agent
> Up for a challenge?

Expand Down
50 changes: 50 additions & 0 deletions sfa_sqlite_add_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# /// script
# dependencies = [
# "sqlite3",
# "os",
# "argparse",
# "uuid",
# ]
# ///

import sqlite3
import os
import argparse
import uuid

def create_table(conn):
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS PythonCode (
id TEXT PRIMARY KEY,
filename TEXT,
code TEXT
)
''')
conn.commit()

def add_code_to_db(conn, directory):
cursor = conn.cursor()
for filename in os.listdir(directory):
if filename.endswith('.py'):
with open(os.path.join(directory, filename), 'r') as file:
code = file.read()
cursor.execute('''
INSERT INTO PythonCode (id, filename, code)
VALUES (?, ?, ?)
''', (str(uuid.uuid4()), filename, code))
conn.commit()

def main():
parser = argparse.ArgumentParser(description="Add Python code to SQLite database")
parser.add_argument('-d', '--db', required=True, help="Path to SQLite database file")
parser.add_argument('-p', '--path', required=True, help="Path to directory containing Python files")
args = parser.parse_args()

conn = sqlite3.connect(args.db)
create_table(conn)
add_code_to_db(conn, args.path)
conn.close()

if __name__ == "__main__":
main()