Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

safe_config #1

Closed
ghost opened this issue Jun 24, 2020 · 4 comments
Closed

safe_config #1

ghost opened this issue Jun 24, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Jun 24, 2020

how to connect postgres to the shelf via safe_config
https://github.com/stablekernel/safe_config

@ghost
Copy link
Author

ghost commented Jun 25, 2020

created the config.yaml file

database:
  host: localhost
  port: 5432
  databaseName: test_db
  username: test_user
  password: gfhjkm

and then what?

@ghost
Copy link
Author

ghost commented Jun 25, 2020

I wrote this swears. Too many positional arguments...
import 'dart:io';
import 'package:postgres/postgres.dart';
import 'package:safe_config/safe_config.dart';

class BackendShelfConfiguration extends Configuration {
BackendShelfConfiguration(String fileName) :
super.fromFile(File(fileName));

DatabaseConfiguration database;
}

void main(List args) async {
final config = BackendShelfConfiguration('config.yaml');
final connectDb = PostgreSQLConnection(
'config.database.host',
'config.database.port',
'config.database.databaseName',
'config.database.username',
'config.database.password',);
await connectDb.open();

print('Подключение прошло успешно!');

await connectDb.close();

@ghost
Copy link
Author

ghost commented Jun 25, 2020

I'm doing everything wrong right?((

@ghost
Copy link
Author

ghost commented Jun 25, 2020

import 'dart:io';
import 'package:postgres/postgres.dart';
import 'package:safe_config/safe_config.dart';

class BackendShelfConfiguration extends Configuration {
BackendShelfConfiguration(String fileName) : super.fromFile(File(fileName));

DatabaseConfiguration database;
}

void main(List args) async {
final config = BackendShelfConfiguration('config.yaml');
final connectDb = PostgreSQLConnection(
config.database.host,
config.database.port,
config.database.databaseName,
username:config.database.username,
password:config.database.password,);
await connectDb.open();

print('Подключение прошло успешно!');

await connectDb.close();
}

@ghost ghost closed this as completed Jun 25, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants