Как в PyCharm перенести базу данных PostgreSQL
Admin 05.10.2020 , обновлено: 08.01.2021 PostgreSQL
Будем переносить локальную базу данных PostgreSQL на удаленные сервер с помощью программы PyCharm.
Чтобы избежать проблем с пользователями при работе с базами данных на разных системах надо придерживаться одинаковых имен, иначе при импорте возникнут ошибки:
Command was: ALTER TABLE public.users_settings_id_seq OWNER TO «UserName»;
pg_restore: from TOC entry 219; 1259 57835 TABLE volumes UserName
pg_restore: error: could not execute query: ERROR: role «UserName» does not exist
В локальной базе данных ставим курсор на public:
И выбираем Export with ‘pg_dump’:
Выбираем параметры как на скрине ниже и экспортируем в удобную нам папку:
Теперь для удаленного сервера также ставим курсор на директорию public, но теперь выбираем пункт Restore with ‘pg_restore’:
Этот процесс не самый быстрый. Возможно, в следующий раз разберем импортирование другим способом.
Читайте также
У сайта нет цели самоокупаться, поэтому на сайте нет рекламы. Но если вам пригодилась информация, можете лайкнуть страницу, оставить комментарий или отправить мне подарок на чашечку кофе.
PyCharm¶
Удаленный доступ с помощью pgAdmin к базе данных Odoo postgre в Ubuntu¶
** Это для интеграции с PgAdmin, но такой же метод работает с PyCharm. **
ШАГ № 1 — получить pgAdmin Установить pgAdmin с pgadmin.org
ШАГ # 2 — разрешить удаленное подключение к серверу postgre отовсюду Откройте файл etc / postgresql / 9.x / main / pg_hba.conf и добавьте следующую строку: host all all all md5
ШАГ # 3 — пусть сервер postgre слушает всех. Откройте etc / postgresql / 9.x / main / postgresql.conf и измените следующую строку: listen_addresses = ‘*’
ШАГ # 4 — дать пользователю «postgres» пароль. Запустите терминал psql: sudo -u postgres psql. Введите пароль: ALTER USER postgres PASSWORD ‘yourpassword’; Оставьте терминал psql: q
ШАГ # 5 Перезапустите сервер postgre, выполнив команду терминала: sudo /etc/init.d/postgresql restart
ШАГ # 6 Запустите pgAdmin и добавьте соединение с сервером следующим образом:
PostgreSQL
This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in PyCharm by default. If the relevant features aren’t available, make sure that you didn’t disable the plugin.
The Database Tools and SQL plugin is available only in PyCharm Professional.
- Press Control+Alt+S to open the IDE settings and then select Plugins .
- Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.
Official documentation and software
- For full information about PostgreSQL, refer to the official documentation.
- To download PostgreSQL database software, refer to the official software downloads.
This topic presents a general procedure on how you can create a data source for the connection to your PostgreSQL database in PyCharm, and run a test connection. It is assumed that you already have the necessary prerequisites and the database is up and running. For example, if you want to run a database on your machine and connect to that database, the corresponding DBMS software must be installed on the machine first.
Connect to a PostgreSQL database
- To connect to the database, create a data source that will store your connection details. You can do this using one of the following ways:
- From the main menu, navigate to File | New | Data Source and select PostgreSQL .
- In the Database tool window ( View | Tool Windows | Database ) , click the New icon () in the toolbar. Navigate to Data Source and select PostgreSQL .
- In the General tab of Data Sources and Drivers dialog right pane, specify the driver and connection type.
- In the Driver list, leave the default driver option, unless another driver is required for your connection.
- From the Connection type list, select the connection type depending on the connection details that you have:
- default : connect by using Host , Port , Database , and URL .
- URL only : connect by using only the URL .
For the URL only connection type, the JDBC URL that you enter is used as is.
For the other connection types, the JDBC URL is broken down into connection details. You can either specify them separately and use the automatically generated URL, or you can enter the URL directly in the corresponding field.
- In the Host field, type your server address.
- In the Port field, type the port of PostgreSQL. The default port is 5432. Real port numbers might be different on your system. Verify that you use a correct port number with your database administrator, server settings, or hosting provider.
- From the Authentication list, select the authentication method that you want to use to authenticate the connection. The following options are available:
- pgpass : by using the pgpass file. You can store this file in the user’s home directory. You can read more about the password file and its location in The Password File at postgresql.org.
- User & Password : by using your login and password.
- No auth : authentication is not required.
- In User and Password fields, type your user credentials. To use no password, leave the Password field empty. To delete a once entered password, right-click the Password field and select Set Empty .
- In the Database field, type the database name to which you want to connect.
- In the URL field, PyCharm generates the JDBC URL automatically using the values of other connection settings. If you need to use a JDBC URL with certain additional settings, paste it in the URL field. The general URL to use is as follows:
- Format: jdbc:postgresql://:/
- Example: jdbc:postgresql://127.0.0.1:5432/myDatabase
For more information about the URL format, refer to the PostgreSQL official documentation.
- From the Authentication list, select the authentication method that you want to use to authenticate the connection. The following options are available:
- User & Password : by using your login and password.
- No auth : authentication is not required.
- In User and Password fields, type your user credentials. To use no password, leave the Password field empty. To delete a once entered password, right-click the Password field and select Set Empty .
- In the URL field, PyCharm generates the JDBC URL automatically using the values of other connection settings. If you need to use a JDBC URL with certain additional settings, paste it in the URL field. For more information about the URL format, refer to the PostgreSQL official documentation.
For the reference information about connection settings and properties on the General and other tabs of Data Sources and Drivers dialog ( Command I ), see Connection settings and DBMS-specific properties.
- For more information about the Database tool window, see the corresponding reference topic. To see more databases and schemas under your new data source node, click the N of M button and select the ones you need. PyCharm will introspect and show them.
- For more information about working with database objects in PyCharm, refer to Database objects.
- To write and run queries, open the default query console by clicking the data source and pressing F4 .
- To view and edit data of a database object, open Data editor and viewer by double-clicking the object.
Connection settings and DBMS-specific properties
Connection settings
For the reference information about connection settings (for example, Host , Port , and so on) on the General and other tabs of Data Sources and Drivers dialog ( Command I ), see Data source settings.
Подключение к удаленной postgresql из Pycharm
Добрый день! У нас есть сервер для разработки на котором установлена Centos 7 и postgres-9.5, не получается в Pycharm подключиться к удаленному серверу. Конфиг /var/lib/pgsql/9.5/data/pg_hba.conf после добавления последней строки выглядит так:
# TYPE DATABASE USER ADDRESS METHOD local all all peer host all all 127.0.0.1/32 password host all all ::1/128 password host all all 0.0.0.0/0 md5
iptables временно отключили В Pycharm далаю такую конфигурацию
Отслеживать
задан 8 окт 2016 в 8:31
381 2 2 серебряных знака 14 14 бронзовых знаков
0
Сортировка: Сброс на вариант по умолчанию
Знаете кого-то, кто может ответить? Поделитесь ссылкой на этот вопрос по почте, через Твиттер или Facebook.
- postgresql
- centos
- postgresql9.5