我有一个使用PostgreSql服务在服务上运行的Scala应用, 表是由数据库管理插件(Slick)创建的
但是,需要编辑特定的表,我找不到它!
postgres服务:
#include <iostream>
#include <string>
#include <vector>
#include <boost/foreach.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/fusion/include/std_tuple.hpp>
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
namespace phx = boost::phoenix;
using V = std::tuple<std::string, double, double, double>;
namespace client {
template <typename Iterator>
struct VGrammar : qi::grammar<Iterator, std::vector<V>()> {
VGrammar() : VGrammar::base_type(start) {
using namespace qi;
v = skip(blank)[no_skip[string("v")] > double_ > double_ > double_];
junk = +(char_ - eol);
start = (v || -junk) % eol;
v.name("v");
junk.name("junk");
start.name("start");
using phx::val;
using phx::construct;
on_error<fail>(
start,
std::cout
<< val("Error! Expecting \n\n'")
<< qi::_4
<< val("'\n\n here: \n\n'")
<< construct<std::string>(qi::_3, qi::_2)
<< val("'")
<< std::endl
);
//debug(v);
//debug(junk);
//debug(start);
}
qi::rule<Iterator> junk;
//qi::rule<Iterator, qi::unused_type()> junk; // Doesn't work either
//qi::rule<Iterator, qi::unused_type(), qi::unused_type()> junk; // Doesn't work either
qi::rule<Iterator, V()> v;
qi::rule<Iterator, std::vector<V>()> start;
};
} // namespace client
int main(int argc, char* argv[]) {
using iterator_type = std::string::const_iterator;
std::string input = "";
input += "v 1 2 3\r"; // keep v 1 2 3
input += "o a b c\r"; // parse as junk
input += "v 4 5 6 v 7 8 9\r"; // keep v 4 5 6, but parse v 7 8 9 as junk
input += " v 10 11 12\r\r"; // parse as junk
iterator_type iter = input.begin();
const iterator_type end = input.end();
std::vector<V> parsed_output;
client::VGrammar<iterator_type> v_grammar;
std::cout << "run" << std::endl;
bool r = parse(iter, end, v_grammar, parsed_output);
std::cout << "done ... r: " << (r ? "true" : "false") << ", iter==end: " << ((iter == end) ? "true" : "false") << std::endl;
if (r && (iter == end)) {
BOOST_FOREACH(V const& v_row, parsed_output) {
std::cout << std::get<0>(v_row) << ", " << std::get<1>(v_row) << ", " << std::get<2>(v_row) << ", " << std::get<3>(v_row) << std::endl;
}
}
return EXIT_SUCCESS;
}
我进入吊舱:
apiVersion: v1
kind: Service
metadata:
name: core-db
spec:
ports:
- port: 5432
selector:
app: core-db
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: core-db
spec:
template:
metadata:
labels:
app: core-db
spec:
containers:
- image: "image"
name: core-db
imagePullPolicy: IfNotPresent
env:
- name: POSTGRES_USER
value: postgres
- name: POSTGRES_PASSWORD
value: postgres
ports:
- containerPort: 5432
name: core-db
volumeMounts:
- name: core-storage
mountPath: /var/lib/postgresql/db-data
volumes:
- name: core-storage
persistentVolumeClaim:
claimName: core-pv-claim
imagePullSecrets:
- name: regcred
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: core-pv-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
但是\ d没有关系
我做错了什么,我的数据到底在哪里?
编辑
kubectl exec POD -it -- psql -U postgres
答案 0 :(得分:1)
我要检查问题出在哪里的步骤:
该应用正在正常运行,如果它正在保留数据,则这些数据应该在某处。
尝试kubectl delete deploy core-db
。该应用程序仍在运行吗?
保存数据?
我希望no
是答案,所以我们可以进行以下几点讨论。
如果答案是yes
,那么问题可能是:
db连接字符串
服务,您有几个端点? kubectl get ep core-db
exec psql pod并连接到postgres db \c postgres
,然后连接到\dt
。桌子在这里吗?
exec psql pod并连接到应用程序数据库\c app
,然后连接到\dt
。桌子在这里吗?
执行psql pod并连接到postgres,然后连接SELECT * FROM pg_stat_activity WHERE datname = 'app';
答案 1 :(得分:1)
好吧,我只是缺少一些大脑活动。
我所有的表都存储在Schema中,这就是我在任何数据库上使用\ dt时都能看到它们的原因
连接到“ app”数据库并使用\ dn将列出架构,因此我们可以找到表。
选择“模式”。表是如何工作的...
感谢@NicolaBen,这些步骤对我有所帮助。