小编Yan*_*hao的帖子

将数据库推送到heroku:如何使用heroku pg:push

我想使用heroku pg:push命令将我的本地postgresql数据库推送到heroku .该命令如下所示:heroku pg:push mylocaldb DATABASE --app sushi根据heroku文档:https://devcenter.heroku.com/articles/heroku-postgresql .

这是我的本地数据库信息:

Name: mysitedb
User: bill
Password: bill
Run Code Online (Sandbox Code Playgroud)

我机器中的DATABASE_URL环境变量设置为:postgres://bill:bill@localhost/mysitedb.

我的应用程序名称是secure-gorge-4090.我试过了heroku pg:push mysitedb DATABASE --app secure-gorge-4090.输出是:

 !    Remote database is not empty.
 !    Please create a new database, or use `heroku pg:reset`
Run Code Online (Sandbox Code Playgroud)

我很惊讶我没有把任何东西放进我的数据库中.但我仍然跑去heroku pg:reset DATABASE重置我的DATABASE.之后,我heroku pg:push mysitedb DATABASE --app secure-gorge-4090再次尝试但输出仍然相同.

我试过了heroku pg:push postgres://bill:bill@localhost:8000/mysitedb DATABASE --app secure-gorge-4090.输出是:

!    LOCAL_SOURCE_DATABASE is not a valid database name
Run Code Online (Sandbox Code Playgroud)

我不知道如何使用此命令将我的本地数据库移动到heroku.我需要你的帮助.谢谢!

heroku database-migration heroku-postgres

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

不同的执行顺序会导致Pthread程序的性能差异

这是我在stackoverflow上的第一篇文章,我的母语不是英语.对于这篇文章带给您的任何不便,请原谅.也许它有点长,所以我很期待你的耐心.提前致谢!

我有一个C语言代码段.这项工作是计算两个文件中的单词数.我使用pthreads来解决这个问题.但我找到了这两个陈述的顺序

count_words(的argv [1]);

pthread_create(&t1,NULL,count_words,(void*)argv [2]);

影响程序性能,这与我的预期相反.这是代码:

#include <stdio.h>
#include <pthread.h>
#include <ctype.h>
#include <stdlib.h>

int total_words;

int main(int argc, char *argv[]) {
    pthread_t t1;
    void *count_words(void *);

    if (argc != 3) {
        printf("usage: %s file1 file2\n", argv[0]);
        exit(1);
    }
    total_words = 0;

    count_words(argv[1]); // program runs faster when executing this first
    pthread_create(&t1, NULL, count_words, (void *)argv[2]);

    pthread_join(t1, NULL);
    printf("%5d: total words\n", total_words);
    return 0;
}

void *count_words(void *f) {
    char *filename = (char *)f;
    FILE *fp;
    int c, …
Run Code Online (Sandbox Code Playgroud)

c unix performance multithreading pthreads

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

pthread程序中例程的额外执行时间是多少?

我写了四个不同的程序来计算两个文件中的总字数.这四个版本看起来大致相同.前三个版本使用两个线程进行计数,只有三个语句的顺序不同.最后一个版本使用一个线程来计算.我将首先列出每个版本的不同部分和公共部分,然后列出每个版本的输出和我的问题.

不同部分:

// version 1
count_words(&file1); 
pthread_create(&new_thread, NULL, count_words, &file2);
pthread_join(new_thread, NULL);

// version 2
pthread_create(&new_thread, NULL, count_words, &file2);
count_words(&file1);
pthread_join(new_thread, NULL);

// version 3
pthread_create(&new_thread, NULL, count_words, &file2);
pthread_join(new_thread, NULL);
count_words(&file1);

// version 4
count_words(&file1);
count_words(&file2);
Run Code Online (Sandbox Code Playgroud)

常见部分:( 将不同部分插入此公共部分以制作完整版本)

#include <stdio.h>
#include <pthread.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>

#define N 2000

typedef struct file_t {
    char *name;
    int words;
} file_t;

double time_diff(struct timespec *, struct timespec *);
void *count_words(void *);

// Usage: progname file1 file2
int main(int …
Run Code Online (Sandbox Code Playgroud)

c linux multithreading runtime pthreads

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

Linux命令在shell命令行中表现奇怪

请看下面的命令:

administrator@ubuntu:~/usp$ cat file
c
b
a
administrator@ubuntu:~/usp$ x="cat file | sort"
administrator@ubuntu:~/usp$ $x
c
b
a
cat: |: ?????????
cat: sort: ?????????
Run Code Online (Sandbox Code Playgroud)

我的问题是为什么$ x的输出不是:

a
b
c
Run Code Online (Sandbox Code Playgroud)

剂量双引号改变命令的行为cat file | sort

bash shell command-line

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