我使用Dropwizard及其JDBI module来连接SQLite数据库。我已经设置了数据库,以便它有FK,但我仍然需要告诉SQLite启用它的约束。
我知道你可以配置它using a properties instance,但我不知道如何在Dropwizard中使用它与JDBI设置一起使用。
答案 0 :(得分:1)
您需要将以下属性添加到.yml设置文件中:foreign_keys: true
。
看起来应该是这样的:
database:
# the name of your JDBC driver
driverClass: org.sqlite.JDBC
# the JDBC URL
url: jdbc:sqlite:databasefile.db
# any properties specific to your JDBC driver:
properties:
foreign_keys: true
之后,您的SQLite数据库中应该有FK约束。您可以查看SQLiteConfig
课程了解更多属性。