小编use*_*599的帖子

psycopg2错误:DatabaseError:错误,没有来自libpq的消息

我有一个应用程序,它将csv文件中的数据解析并加载到Postgres 9.3数据库中.在串行执行中,插入语句/游标执行没有问题.

我在混合中添加了celery以添加并行解析和插入数据文件.解析工作正常.但是,我去运行插入语句,我得到:

[2015-05-13 11:30:16,464:  ERROR/Worker-1] ingest_task.work_it: Exception
    Traceback (most recent call last):
    File "ingest_tasks.py", line 86, in work_it
        rowcount = ingest_data.load_data(con=con, statements=statements)
    File "ingest_data.py", line 134, in load_data
        ingest_curs.execute(statement)
    DatabaseError: error with no message from the libpq
Run Code Online (Sandbox Code Playgroud)

python postgresql psycopg celery python-multiprocessing

12
推荐指数
1
解决办法
3244
查看次数

是否有任何 NoSQL 数据库支持某种类型的行级安全性或标签安全性?

我仍在学习 NoSQL 数据库及其功能。我关心的问题之一是能够应用类似于 Oracle 安全标签或某种类型的行级安全性的东西。NoSQL 数据库是否支持类似的功能?对于基于文档的数据库或列族风格的数据库来说,这是否可能?

nosql

5
推荐指数
0
解决办法
600
查看次数

芹菜工厂功能与进口芹菜

我正在开发Flask应用程序并利用蓝图.我计划使用芹菜任务队列.我试图了解使用类似的东西的好处或原因

def make_celery(app):
    celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task
    class ContextTask(TaskBase):
        abstract = True
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)
    celery.Task = ContextTask
    return celery
Run Code Online (Sandbox Code Playgroud)

然后做

celery = make_celery(app) 
Run Code Online (Sandbox Code Playgroud)

并将其导入我的tasks.py,而不是仅在我的tasks.py中导入和创建芹菜实例

from celery import Celery

app = Celery('hello', broker='amqp://guest@localhost//')
@app.task
def mytask():
Run Code Online (Sandbox Code Playgroud)

python celery flask

5
推荐指数
1
解决办法
633
查看次数

Airflow PythonVirtualenvOperator,没有这样的文件或目录:'virtualenv'

我正在尝试在我的 DAG 之一中运行 Apache Airflow PythonVirtualenvOperator,但 Airflow 抛出以下错误:

[2020-12-14 20:06:32,291] {python_operator.py:316} INFO - Executing cmd
['virtualenv', '/tmp/venvwtqb3rki', '--python=python3.8']
[2020-12-14 20:06:32,301] {taskinstance.py:1150} ERROR - [Errno 2] No such file or directory: 'virtualenv'
Traceback (most recent call last):
  File "/opt/airflow/airflow_env/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 984, in _run_raw_task
    result = task_copy.execute(context=context)
  File "/opt/airflow/airflow_env/lib/python3.8/site-packages/airflow/operators/python_operator.py", line 113, in execute
    return_value = self.execute_callable()
  File "/opt/airflow/airflow_env/lib/python3.8/site-packages/airflow/operators/python_operator.py", line 292, in execute_callable
    self._execute_in_subprocess(self._generate_virtualenv_cmd(tmp_dir))
  File "/opt/airflow/airflow_env/lib/python3.8/site-packages/airflow/operators/python_operator.py", line 317, in _execute_in_subprocess
    output = subprocess.check_output(cmd,
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, …
Run Code Online (Sandbox Code Playgroud)

python airflow

5
推荐指数
1
解决办法
4267
查看次数

在Python中将对象属性传递给函数的最佳方法是什么?

我确信即使它有效,我也会"错误地"这样做.现在,当我调用一个函数时,我只是传递了整个对象,即

class my_file_obj:
    def __init__(self,filename):
        self.filename = filename
        self.owner = None
        self.file_type = None
        self.fileflag = 0
        self.md5 = None
Run Code Online (Sandbox Code Playgroud)

函数调用,其中file_obj1是一个实例my_file_obj:

some_function(file_obj1)
Run Code Online (Sandbox Code Playgroud)

然后根据需要在函数中引用我需要的属性.

什么是"python"/正确的做法?

  • some_function(file_obj1)

  • some_function(file_obj1.filename)

  • the_filename = file_obj1.filename
    some_function(the_filename)

python oop

2
推荐指数
1
解决办法
129
查看次数

启动mongodb副本集

我在脚本中运行以下内容以自动启动副本集:

var cfg = { _id: 'rs0',
    members: [
        { _id: 0, host: '192.168.1.46:27017'},
        { _id: 1, host: '192.168.1.51:27017'},
        { _id: 2, host: '192.168.1.48:27017'}
    ]
};

var error = rs.initiate(cfg);
printjson(error);
Run Code Online (Sandbox Code Playgroud)

但是我得到了:

{ "ok" : 0, "errmsg" : "Missing expected field \"version\"", "code" : 93 }
Run Code Online (Sandbox Code Playgroud)

我运行脚本后,我不知道为什么.

我已经尝试在本地运行脚本,使用以下内容:

mongo 192.168.1.46:27017 /opt/scripts/initreplset.js
Run Code Online (Sandbox Code Playgroud)

我正在使用mongodb v3.2.

mongodb

1
推荐指数
1
解决办法
1692
查看次数