35 lines
No EOL
896 B
Dart
35 lines
No EOL
896 B
Dart
import 'package:postgres/postgres.dart' as pg;
|
|
|
|
void main() async {
|
|
print('Testing PostgreSQL connection...');
|
|
|
|
try {
|
|
// Direct PostgreSQL connection test
|
|
final connection = await pg.Connection.open(
|
|
pg.Endpoint(
|
|
host: 'localhost',
|
|
port: 5432,
|
|
database: 'mnemo_cards_dev',
|
|
username: 'mnemo_user',
|
|
password: 'dev_password_change_me',
|
|
),
|
|
settings: pg.ConnectionSettings(
|
|
sslMode: pg.SslMode.disable,
|
|
),
|
|
);
|
|
|
|
print('✅ PostgreSQL connection successful');
|
|
|
|
// Test query
|
|
final result = await connection.execute('SELECT 1 as test');
|
|
print('✅ Query executed successfully');
|
|
|
|
await connection.close();
|
|
print('✅ Database connection closed');
|
|
print('🎉 PostgreSQL backend can connect to database!');
|
|
|
|
} catch (e, s) {
|
|
print('❌ Error: $e');
|
|
print('Stack trace: $s');
|
|
}
|
|
} |