37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
import postgres from 'postgres';
|
|
|
|
const DATABASE_URL = "postgres://postgres:xGhPj4IuE5VocaxUoYAj1dSr2xf6M3hh3c2C6YbnB7ZOeVJLRvmL0mzCbhvf14dh@65.109.236.58:8392/postgres";
|
|
|
|
const sql = postgres(DATABASE_URL);
|
|
|
|
async function checkDb() {
|
|
try {
|
|
console.log('Connecting to database...');
|
|
|
|
const settings = await sql`SELECT * FROM settings LIMIT 1`;
|
|
const servicesCount = await sql`SELECT COUNT(*) FROM services`;
|
|
const projectsCount = await sql`SELECT COUNT(*) FROM projects`;
|
|
const leadsCount = await sql`SELECT COUNT(*) FROM leads`;
|
|
|
|
console.log('\n--- Database Connection Successful ---');
|
|
console.log('Settings:', settings[0]);
|
|
console.log('Services Count:', servicesCount[0].count);
|
|
console.log('Projects Count:', projectsCount[0].count);
|
|
console.log('Leads Count:', leadsCount[0].count);
|
|
|
|
if (parseInt(projectsCount[0].count) > 0) {
|
|
const projects = await sql`SELECT title, category FROM projects LIMIT 5`;
|
|
console.log('\n--- Recent Projects ---');
|
|
console.table(projects);
|
|
}
|
|
|
|
await sql.end();
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Database connection error:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
checkDb();
|