Towniequeries.tsx1 match
4import { INFERENCE_CALLS_TABLE, USAGE_TABLE } from "./schema.tsx";
56// Eventually we'll have a user database,
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
Townie.cursorrules2 matches
198```
199โโโ backend/
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
257```
258259### Database Patterns
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
cerebras_codermain.tsx2 matches
1import { serveFile } from "https://esm.town/v/std/utils/index.ts";
2import { generateCode } from "./backend/generate-code.ts";
3import { createTables } from "./database/migrations.ts";
4import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries.ts";
56await createTables();
cerebras_codermain.tsx2 matches
1import { serveFile } from "https://esm.town/v/std/utils/index.ts";
2import { generateCode } from "./backend/generate-code.ts";
3import { createTables } from "./database/migrations.ts";
4import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries.ts";
56await createTables();
con-juanindex.html19 matches
124</label>
125<label class="flex items-center text-sm">
126<input type="radio" name="privacy-mode" value="database" class="mr-2">
127<span>โ๏ธ Save to server (shareable, persistent)</span>
128</label>
300</label>
301<label class="flex items-start text-sm">
302<input type="radio" name="modal-privacy-mode" value="database" class="mr-2 mt-0.5">
303<div>
304<span class="font-medium">โ๏ธ Save to server</span>
552statusText = 'Local mode - data saved in browser only';
553break;
554case 'database':
555statusText = 'Server mode - data saved on server';
556break;
567statusText = `${localCount} session(s) in browser`;
568clearLocalDataBtn.style.display = localCount > 0 ? 'block' : 'none';
569} else if (state.privacyMode === 'database') {
570statusText = `${serverCount} session(s) on server`;
571clearServerDataBtn.style.display = serverCount > 0 ? 'block' : 'none';
580clearLocalDataBtn.style.display = 'none';
581}
582if (state.privacyMode !== 'database') {
583clearServerDataBtn.style.display = 'none';
584}
652async function loadSessions() {
653try {
654if (state.privacyMode === 'database') {
655// Load from server database
656const response = await fetch('/chat-api', {
657method: 'POST',
719if (state.privacyMode === 'local') {
720privacyIndicator = '<span class="text-xs text-blue-500">๐พ</span>';
721} else if (state.privacyMode === 'database') {
722privacyIndicator = '<span class="text-xs text-green-500">โ๏ธ</span>';
723}
756if (confirm('Are you sure you want to delete this session?')) {
757try {
758if (state.privacyMode === 'database') {
759await fetch('/chat-api', {
760method: 'POST',
792let sessionData = null;
793
794if (state.privacyMode === 'database') {
795// Load from server
796const response = await fetch('/chat-api', {
840indicator = '<span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded">๐พ Local</span>';
841break;
842case 'database':
843indicator = '<span class="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">โ๏ธ Server</span>';
844break;
883
884try {
885if (state.privacyMode === 'database') {
886await fetch('/chat-api', {
887method: 'POST',
1011let newSession = null;
1012
1013if (selectedMode === 'database') {
1014// Create on server
1015const response = await fetch('/chat-api', {
1080indicator = '<span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded">๐พ Local</span>';
1081break;
1082case 'database':
1083indicator = '<span class="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">โ๏ธ Server</span>';
1084break;
1101privacyMessage = '๐พ This session is saved locally in your browser only.';
1102break;
1103case 'database':
1104privacyMessage = 'โ๏ธ This session is saved on the server and can be accessed from any device.';
1105break;
1146
1147try {
1148if (state.privacyMode === 'database') {
1149await fetch('/chat-api', {
1150method: 'POST',
1209if (!text) return;
1210
1211// Check if we need to create a session first (only for database mode)
1212if (!state.currentSession && state.privacyMode === 'database') {
1213showNewSessionModal();
1214return;
1275let messageResponse = null;
1276
1277if (state.privacyMode === 'database') {
1278// Send to server for processing
1279const response = await fetch('/chat-api', {
136<div>
137<h3 class="text-xl font-medium text-blue-300">4. Storage</h3>
138<p class="mt-1">The generated blog is saved in a database so you can access it later using the same link.</p>
139</div>
140</div>
11});
1213// Sample data - in a real app, this would come from a database
14const sampleGalleryItems: GalleryItem[] = [
15{
sqliteExplorerAppREADME.md1 match
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
vibeCoding_PLPapi.py2 matches
5from datetime import datetime, timedelta
67from database.connection import get_db_connection, prepare_json_field, parse_json_field
8from database.models import (
9Store, StoreCreate, Product, ProductCreate, Transaction, TransactionCreate,
10Category, CategoryCreate, FinancialHealth, DashboardData, ApiResponse,
vibeCoding_PLPconnection.py13 matches
6from datetime import datetime
78# Database configuration
9DB_CONFIG = {
10'host': os.getenv('MYSQL_HOST', 'localhost'),
12'user': os.getenv('MYSQL_USER', 'root'),
13'password': os.getenv('MYSQL_PASSWORD', ''),
14'database': os.getenv('MYSQL_DATABASE', 'storefront_builder'),
15'charset': 'utf8mb4',
16'collation': 'utf8mb4_unicode_ci'
17}
1819class DatabaseConnection:
20def __init__(self):
21self.connection = None
71return False
7273# Global database connection instance
74db = DatabaseConnection()
7576async def get_db_connection():
79return db
8081async def init_database():
82"""Initialize database and create tables if they don't exist"""
83try:
84# First, create database if it doesn't exist
85temp_config = DB_CONFIG.copy()
86temp_config.pop('database', None)
87
88temp_connection = mysql.connector.connect(**temp_config)
89temp_cursor = temp_connection.cursor()
90
91temp_cursor.execute(f"CREATE DATABASE IF NOT EXISTS {DB_CONFIG['database']} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci")
92temp_cursor.close()
93temp_connection.close()
94
95# Now connect to the database and create tables
96await db.connect()
97
99await create_tables()
100
101print("Database initialized successfully!")
102
103except Error as e:
104print(f"Error initializing database: {e}")
105raise e
106