Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want set my collation in postgresql with pgadmin3:
how do see a list list of local collation names in Ubuntu?
How do I set the collation in PgAdmin-III?
I want set Persian collation for my database in Ubuntu
(I know how to create collation in pgadmin , but i don't know how to set this for my database?)
To list all locales on Ubuntu you can use locale -a. The linked page also shows how to configure locales.
AFAIK collation support in glibc is part of the locale/encoding configuration.
You can't alter the collation of an existing database safely or easily, because indexes etc would become suddenly invalid. To set the collation when creating a new database on an existing instance of PostgreSQL use:
CREATE DATABASE somedb
TEMPLATE template0
ENCODING = 'UTF-8'
LC_COLLATE = 'fa_IR'
LC_CTYPE='fa_IR.UTF-8';
You can dump your existing DB then reload to this one.
I don't recommend trying to change the default encoding / locale of a DB on Ubuntu; you'd have to pg_dropcluster the db, then pg_createcluster a new one with different settings. Just CREATE DATABASE with appropriate settings.
I have no idea what you mean with (2), how to "set the collation in PgAdmin-III".
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 14 days ago.
Improve this question
I am trying to use Postgres with Django application.
I am using pgAdmin to manage Postgres database.
But I can't add new item to database using pgAdmin manually.
Once I typed data manually and clicked the save button, I got
ERROR: invalid input syntax for type uuid: "111"
LINE 3: '111'::uuid, 'asdfasdfdasf'::character varying)
^
Schema is just simple.
Just id and name in the table.
Please help me to fix the issue.
Thank you.
Try to add a default auto-generated value for your id field with the following commands:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
ALTER TABLE public.table_name
ALTER COLUMN "id" SET DEFAULT uuid_generate_v4();
After that, you need to populate only the name column.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
How can I link a Google spreadsheet to PostgreSQL? I googled and got some sample code for MySQL, and a couple of products which do it. As per this link ,support exists for a few databases.
My approach is using R and its googlesheets and DBI libraries. Googlesheets connects the spreadsheet with R and DBI connects the R with PostgreSQL. You can update the table whenever you want by simply running the script. With this approach you can also add transformations to the data before storing them in PostgreSQL. Another way is using Python and pandas and gspread libraries.
More info:
Googlesheets: https://cran.r-project.org/web/packages/googlesheets/vignettes/basic-usage.html
DBI: https://cran.r-project.org/web/packages/DBI/vignettes/DBI-1.html
We have been pulling Google Sheets into QGIS via PostgreSQL Foreign Data Wrappers. We then build a materialized view that connects records to geometry (via School Numbers, for example) and use the materialized view as a standard spatial table.
From there we have also published this 'google sheet materialized view' to a web application via node.js and add a button to refresh the map if the google sheet data has been changed. It works really well.
Method 1: Multicorn FDW and GSheets Extension:
(Note: The gsspreadsheet extension to the multicorn FDW is questionably maintained, and there is the risk that v4 of the GSheets API may break it... we don't know yet, and are planning for the possibility that we might have to implement Method 2 (below) if it does indeed break. )
To connect to a Google Sheet via a PostgreSQL FDW, use the Multicorn FDW:
https://github.com/Kozea/Multicorn
Then install the gspreadsheet_fdw extension for Multicorn:
https://github.com/lincolnturner/gspreadsheet_fdw
In PostgreSQL, create the multicorn FDW:
CREATE SERVER multicorn_gspreadsheet
FOREIGN DATA WRAPPER multicorn
OPTIONS (wrapper 'gspreadsheet_fdw.GspreadsheetFdw');
Then create the FDW table connecting to the Google Sheet using the gspreadsheet extension of multicorn:
CREATE FOREIGN TABLE speced_fdw.centerprogram_current_gsheet (
column1 integer NULL,
column2 varchar NULL,
column3 varchar NULL
)
SERVER multicorn_gspreadsheet
OPTIONS (keyfile '/usr/pgsql-9.5/share/credential.json', gskey 'example_d33lk2kdislids');
You now have a foreign table pointing directly to your Google Sheet, which you can built a materialized view from.
Method 2: Using FILE_FDW and CSV GSheet Export:
The other option is to use the FILE_FDW right out of PostgreSQL and connect to the CSV export of the GSheet using WGET.
First, create the server:
CREATE SERVER fdw_files
FOREIGN DATA WRAPPER file_fdw
OPTIONS ()
Then create the FDW table:
CREATE FOREIGN TABLE public.test_file_fdw (
"name" varchar NOT NULL,
"date" varchar NULL,
"address" varchar NULL
)
SERVER fdw_files
OPTIONS (program 'wget -q -O - "https://docs.google.com/spreadsheets/d/2343randomurlcharacters_r0/export?gid=969976&format=csv"', format 'csv', header 'true');
The above options for wget are listed here: https://www.gnu.org/software/wget/manual/html_node/HTTP-Options.html
You can do this using Google app script and database connector like psycopg2 if you're using python or node-postgres if you're using node. Run your db connector on some server, front it with a REST API and fetch the data using app script from google sheet.
One thing you'd need to figure out is permissions (Google calls them scopes).
You can build an addon and publish it internally. Here is a good tutorial on how to do this.
If you don't want to build your own addon, you can use database connectors like Castodia, Kpibees and Seekwell from Google marketplace. Most of them support Postgres.
Wow, I forgot about this question. I got this working by making an additional MySQL database for two databases. The Mysql database had a single table which was used to talk to the google sheets api. In turn this mysql table was a foreign table in the Postgres database.
I have a Postgres 9.3 database which, by mistake, has been set to:
but I need it to be:
Since the Encoding doesn't change, it is safe to dump the DB and restore it later (see here) to a database with the new Collation / Character type?
Perfectly safe -- the collation is just telling Postgres which set of rules to apply when sorting text.
You can even set it dynamically on a query basis in the order by clause, and should be able to alter it without needing to dump the database.
I'm using postgreSQL 9.1
I've set the Collation and the Character Type of the database to Greek_Greece.1253 and I want to change it to utf8
To change the collation I should use this, right?
But how can I change the character type?
Thanks
EDIT
I ment to wright C instead of utf8. I would like to change the Collation and the Character Type to C
You cannot change default collation of an existing database. You need to CREATE DATABASE with the collation you need and then dump/restore your schema and data into it.
If you do not want to recreate the database - you can specify collation for every text collumn in your db.
Here is detailed postgres manual on collations: Collation Support.
First line of this manual page states:
LC_COLLATE and LC_CTYPE settings of a database cannot be changed after
its creation.
CREATE DATABASE, pg_dump, pg_restore
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I create tables with data studio but when I try to access that table from java application, or db2 command console, I get -204 which means the object that I am trying to access is not defined. But in fact it is defined, because I am able to list the tables in db2 command console, but I am not able to select or insert into that table. Please help me if possible. I've already spent 1.5 day on this.
Let's suppose you are using the johndoe user.
How are you creating the tables?
create table myTable (col1 int)
Or like this
create table myschema.myTable (col1 int)
The first table will be created in the catalog as follow:
johndoe.myTable
The second one as
myschema.myTable
As you can see, if no schema is specified, the username will be used as schema.
You can check the tables currently created in db2 with this query
select varchar(tabschema,20), varchar(tabname, 20)
from syscat.tables
where tabschema not like 'SYS%'
In this way you will know what exist in the database.