如何设置 ODBC .DSN 文件以允许其访问 Postgresql 中的任何数据库?

发布于 2024-07-08 11:11:52 字数 396 浏览 8 评论 0原文

我正在编写一个 MFC 应用程序来自动使用 ODBC 配置 Postgresql 供另一个应用程序使用。 这个想法是,用户运行应用程序,它会自动创建数据库和其中的表。 我的问题是,当我设置文件 DSN 时,它似乎需要它将访问的数据库的名称。 这在 DSN 文件中显示为 ..

DATABASE=mydb

但是我还没有创建 mydb 所以无法连接到 Postgresql ! 我尝试编辑 DSN 文件,因此该行显示为 ..

DATABASE=

并将其完全删除,但随后出现错误并且无法连接。

DSN 文件是否可以允许访问任何数据库? 如果是这样我该怎么做?

谢谢伊恩

I'm writing an MFC App to automatically configure Postgresql with ODBC for use by another app. The idea being that the user runs the app and it automatically creates the database and the tables within it. My problem is that when I set up the File DSN it seems to require the name of the database it will access. This appears in the DSN file as ..

DATABASE=mydb

However I haven't created mydb yet so can't connect to Postgresql ! I have tried editing the DSN file so this line reads ..

DATABASE=

and removing it totally but then I get an error and can't connect.

Is it possible for a DSN file to allow access to any database ? If so how do I do this ?

Thanks

Ian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

走过海棠暮 2024-07-15 11:11:52

我不熟悉 PostgreSql,但是 SQL Server 中是否有像“master”这样的数据库,您可以首先连接到该数据库,然后再使用其他数据库?
您可能还想尝试 connectionstrings.com

I am not familiar with PostgreSql, but is there a database like 'master' in SQL Server that you could initially connect to, and then later use a different database?
You might also want to try connectionstrings.com

素染倾城色 2024-07-15 11:11:52

PostgreSQL 的数据库“postgres”始终存在,并且可用于执行此类任务。

The database 'postgres' always exists for PostgreSQL and can be used for tasks like these.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文