SlideShare uma empresa Scribd logo
1 de 2
Baixar para ler offline
selvamani@selvamani-laptop:~$ sudo su - postgres
[sudo] password for selvamani:
postgres@selvamani-laptop:~$ psql -U pgsqldemouser pgsqldemodb
psql (8.4.3)
Type "help" for help.

pgsqldemodb=> create table pgsqldemotable(sno varchar(3), name varchar(30));
CREATE TABLE
pgsqldemodb=> insert into pgsqldemotable values('1','Arulalan');
INSERT 0 1
pgsqldemodb=> insert into pgsqldemotable values('2','BalaKrishnan');
INSERT 0 1
pgsqldemodb=> insert into pgsqldemotable values('3','Dhasthagheer');
INSERT 0 1
pgsqldemodb=> insert into pgsqldemotable values('4','Selvamani');
INSERT 0 1
pgsqldemodb=> select * from pgsqldemotable;
 sno | name
-----+--------------
 1 | Arulalan
 2 | BalaKrishnan
 3 | Dhasthagheer
 4 | Selvamani
(4 rows)

pgsqldemodb=> alter role pgsqldemouser with password 'demo';
ALTER ROLE
pgsqldemodb=> q
postgres@selvamani-laptop:~$ logout
selvamani@selvamani-laptop:~$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> connection=psycopg2.connect("host=localhost dbname=pgsqldemodb user=pgsqldemouser
password=demo")
cur=connection.cursor()
>>> cur.execute("""select * from pgsqldemotable""")
>>> a=cur.fetchall()
>>> print a
[('1', 'Arulalan'), ('2', 'BalaKrishnan'),('3','Dhasthagheer'), ('4', 'Selvamani')]
>>> type(a)
<type 'list'>
>>> type(a[0])
<type 'tuple'>
>>> type(a[0][0])
<type 'str'>
>>> type(a[0][1])
<type 'str'>
>>> a[0][1]
'Arulalan'
>>> a[1][1]
'BalaKrishnan'
>>> cur.execute("""insert into pgsqldemotable values('5','Rajkumar')""")
>>> connection.commit()
>>> sno=raw_input("""Enter the value:""")
Enter the value:6
>>> name=raw_input("""Enter the value:""")
Enter the value:Shrinivasan
>>> cur.execute("""insert into pgsqldemotable values('%s','%s')""" %(sno,name))
>>> connection.commit()
>>> exit()
selvamani@selvamani-laptop:~$ sudo su - postgres
postgres@selvamani-laptop:~$ psql -U pgsqldemouser -W pgsqldemodb
Password for user pgsqldemouser:
psql (8.4.3)
Type "help" for help.

pgsqldemodb=> select * from pgsqldemotable;
 sno | name
-----+--------------
 1 | Arulalan
 2 | BalaKrishnan
 3 | Dhasthagheer
 4 | Selvamani
 5 | Rajkumar
 6 | Shrinivasan
(6 rows)

pgsqldemodb=> q
postgres@selvamani-laptop:~$ logout
selvamani@selvamani-laptop:~$

Mais conteúdo relacionado

Mais procurados

Solr integration in Magento Enterprise
Solr integration in Magento EnterpriseSolr integration in Magento Enterprise
Solr integration in Magento Enterprise
Tobias Zander
 
You Don't Need Lodash
You Don't Need Lodash You Don't Need Lodash
You Don't Need Lodash
UpsideTravel
 
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet Camp Amsterdam 2015: Manifests of Future PastPuppet Camp Amsterdam 2015: Manifests of Future Past
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet
 
PostgreSQL (2) by Aswin
PostgreSQL (2) by AswinPostgreSQL (2) by Aswin
PostgreSQL (2) by Aswin
Agate Studio
 
Pontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11gPontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11g
Leandro Santos
 

Mais procurados (20)

20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia
 
ランダム文字ぽいものをつくる
ランダム文字ぽいものをつくるランダム文字ぽいものをつくる
ランダム文字ぽいものをつくる
 
Advanced Shell Scripting
Advanced Shell ScriptingAdvanced Shell Scripting
Advanced Shell Scripting
 
Drush - use full power - DrupalCamp Donetsk 2014
Drush - use full power - DrupalCamp Donetsk 2014Drush - use full power - DrupalCamp Donetsk 2014
Drush - use full power - DrupalCamp Donetsk 2014
 
NUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialNUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline Tutorial
 
Linux Command Line
Linux Command LineLinux Command Line
Linux Command Line
 
Leaks & Zombies
Leaks & ZombiesLeaks & Zombies
Leaks & Zombies
 
Solr integration in Magento Enterprise
Solr integration in Magento EnterpriseSolr integration in Magento Enterprise
Solr integration in Magento Enterprise
 
テストデータどうしてますか?
テストデータどうしてますか?テストデータどうしてますか?
テストデータどうしてますか?
 
WordPress Cuztom Helper
WordPress Cuztom HelperWordPress Cuztom Helper
WordPress Cuztom Helper
 
How to send files to remote server via ssh in php
How to send files to remote server via ssh in phpHow to send files to remote server via ssh in php
How to send files to remote server via ssh in php
 
Couchdb
CouchdbCouchdb
Couchdb
 
You Don't Need Lodash
You Don't Need Lodash You Don't Need Lodash
You Don't Need Lodash
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Puppet Camp Amsterdam 2015: Manifests of Future Past
Puppet Camp Amsterdam 2015: Manifests of Future PastPuppet Camp Amsterdam 2015: Manifests of Future Past
Puppet Camp Amsterdam 2015: Manifests of Future Past
 
MongoDB
MongoDBMongoDB
MongoDB
 
Report: Avalanche 'very likely' to host outdoor game at Coors Field
Report: Avalanche 'very likely' to host outdoor game at Coors FieldReport: Avalanche 'very likely' to host outdoor game at Coors Field
Report: Avalanche 'very likely' to host outdoor game at Coors Field
 
Linux system admin
Linux system adminLinux system admin
Linux system admin
 
PostgreSQL (2) by Aswin
PostgreSQL (2) by AswinPostgreSQL (2) by Aswin
PostgreSQL (2) by Aswin
 
Pontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11gPontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11g
 

Destaque (7)

Michael Campbell Visual Resume PCP
Michael Campbell Visual Resume PCPMichael Campbell Visual Resume PCP
Michael Campbell Visual Resume PCP
 
Ps
PsPs
Ps
 
Bcom 275 final exam guide 19) Which verbal support breaks down complex proces...
Bcom 275 final exam guide 19) Which verbal support breaks down complex proces...Bcom 275 final exam guide 19) Which verbal support breaks down complex proces...
Bcom 275 final exam guide 19) Which verbal support breaks down complex proces...
 
Emmelibri
EmmelibriEmmelibri
Emmelibri
 
Dream the work retreat agenda
Dream the work retreat agendaDream the work retreat agenda
Dream the work retreat agenda
 
EDRM LegalTech NY 2009 Luncheon Presentation
EDRM LegalTech NY 2009 Luncheon PresentationEDRM LegalTech NY 2009 Luncheon Presentation
EDRM LegalTech NY 2009 Luncheon Presentation
 
Gsj11 bcn interesting websites
Gsj11 bcn interesting websitesGsj11 bcn interesting websites
Gsj11 bcn interesting websites
 

Semelhante a Klug pgsql tut

Полнотекстовый поиск в PostgreSQL / Александр Алексеев (Postgres Professional)
Полнотекстовый поиск в PostgreSQL / Александр Алексеев (Postgres Professional)Полнотекстовый поиск в PostgreSQL / Александр Алексеев (Postgres Professional)
Полнотекстовый поиск в PostgreSQL / Александр Алексеев (Postgres Professional)
Ontico
 
My sql presentation
My sql presentationMy sql presentation
My sql presentation
Nikhil Jain
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdf
michardsonkhaicarr37
 

Semelhante a Klug pgsql tut (20)

Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonbСтажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014
 
Full Text Search in PostgreSQL
Full Text Search in PostgreSQLFull Text Search in PostgreSQL
Full Text Search in PostgreSQL
 
Полнотекстовый поиск в PostgreSQL / Александр Алексеев (Postgres Professional)
Полнотекстовый поиск в PostgreSQL / Александр Алексеев (Postgres Professional)Полнотекстовый поиск в PostgreSQL / Александр Алексеев (Postgres Professional)
Полнотекстовый поиск в PostgreSQL / Александр Алексеев (Postgres Professional)
 
PostgreSQL: How to Store Passwords Safely
PostgreSQL: How to Store Passwords SafelyPostgreSQL: How to Store Passwords Safely
PostgreSQL: How to Store Passwords Safely
 
Getting Started with PL/Proxy
Getting Started with PL/ProxyGetting Started with PL/Proxy
Getting Started with PL/Proxy
 
Mysql quick guide
Mysql quick guideMysql quick guide
Mysql quick guide
 
Codigos
CodigosCodigos
Codigos
 
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeSCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
 
MoSQL: More than SQL, but less than ORM
MoSQL: More than SQL, but less than ORMMoSQL: More than SQL, but less than ORM
MoSQL: More than SQL, but less than ORM
 
Lekcja stylu
Lekcja styluLekcja stylu
Lekcja stylu
 
281 Rac
281 Rac281 Rac
281 Rac
 
281 Pdfsam
281 Pdfsam281 Pdfsam
281 Pdfsam
 
OpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQL
 
My sql presentation
My sql presentationMy sql presentation
My sql presentation
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdf
 
Postgresql 12 streaming replication hol
Postgresql 12 streaming replication holPostgresql 12 streaming replication hol
Postgresql 12 streaming replication hol
 
Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL Indexes
 
greenDAO
greenDAOgreenDAO
greenDAO
 
groovy databases
groovy databasesgroovy databases
groovy databases
 

Mais de selvamanisampath

Mais de selvamanisampath (6)

Unix commands
Unix commandsUnix commands
Unix commands
 
Panipuri an-introduction-to-perfection-in-food-design
Panipuri an-introduction-to-perfection-in-food-designPanipuri an-introduction-to-perfection-in-food-design
Panipuri an-introduction-to-perfection-in-food-design
 
Death by-powerpoint4344
Death by-powerpoint4344Death by-powerpoint4344
Death by-powerpoint4344
 
Glade & PYGTK
Glade & PYGTKGlade & PYGTK
Glade & PYGTK
 
History Of Couch Db
History Of Couch DbHistory Of Couch Db
History Of Couch Db
 
Intro Couchdb
Intro CouchdbIntro Couchdb
Intro Couchdb
 

Klug pgsql tut

  • 1. selvamani@selvamani-laptop:~$ sudo su - postgres [sudo] password for selvamani: postgres@selvamani-laptop:~$ psql -U pgsqldemouser pgsqldemodb psql (8.4.3) Type "help" for help. pgsqldemodb=> create table pgsqldemotable(sno varchar(3), name varchar(30)); CREATE TABLE pgsqldemodb=> insert into pgsqldemotable values('1','Arulalan'); INSERT 0 1 pgsqldemodb=> insert into pgsqldemotable values('2','BalaKrishnan'); INSERT 0 1 pgsqldemodb=> insert into pgsqldemotable values('3','Dhasthagheer'); INSERT 0 1 pgsqldemodb=> insert into pgsqldemotable values('4','Selvamani'); INSERT 0 1 pgsqldemodb=> select * from pgsqldemotable; sno | name -----+-------------- 1 | Arulalan 2 | BalaKrishnan 3 | Dhasthagheer 4 | Selvamani (4 rows) pgsqldemodb=> alter role pgsqldemouser with password 'demo'; ALTER ROLE pgsqldemodb=> q postgres@selvamani-laptop:~$ logout selvamani@selvamani-laptop:~$ python Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import psycopg2 >>> connection=psycopg2.connect("host=localhost dbname=pgsqldemodb user=pgsqldemouser password=demo") cur=connection.cursor() >>> cur.execute("""select * from pgsqldemotable""") >>> a=cur.fetchall() >>> print a [('1', 'Arulalan'), ('2', 'BalaKrishnan'),('3','Dhasthagheer'), ('4', 'Selvamani')] >>> type(a) <type 'list'> >>> type(a[0]) <type 'tuple'> >>> type(a[0][0]) <type 'str'> >>> type(a[0][1]) <type 'str'> >>> a[0][1] 'Arulalan' >>> a[1][1]
  • 2. 'BalaKrishnan' >>> cur.execute("""insert into pgsqldemotable values('5','Rajkumar')""") >>> connection.commit() >>> sno=raw_input("""Enter the value:""") Enter the value:6 >>> name=raw_input("""Enter the value:""") Enter the value:Shrinivasan >>> cur.execute("""insert into pgsqldemotable values('%s','%s')""" %(sno,name)) >>> connection.commit() >>> exit() selvamani@selvamani-laptop:~$ sudo su - postgres postgres@selvamani-laptop:~$ psql -U pgsqldemouser -W pgsqldemodb Password for user pgsqldemouser: psql (8.4.3) Type "help" for help. pgsqldemodb=> select * from pgsqldemotable; sno | name -----+-------------- 1 | Arulalan 2 | BalaKrishnan 3 | Dhasthagheer 4 | Selvamani 5 | Rajkumar 6 | Shrinivasan (6 rows) pgsqldemodb=> q postgres@selvamani-laptop:~$ logout selvamani@selvamani-laptop:~$