Python Programming for Biology: Bioinformatics and Beyond



Download 7,75 Mb.
Pdf ko'rish
bet304/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   300   301   302   303   304   305   306   307   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Running SQL

We  can  run  the  SQL  program  at  the  operating-system  prompt  (‘>’)  and  then  type  the

command (or, more generally, commands) at the ‘SQL prompt’. For example, in SQLite a

session might take the form:

> sqlite3 PersonDb

… (information printed out by the program)

sqlite> CREATE TABLE Person (

…> firstName VARCHAR(30) NOT NULL,

…> lastName VARCHAR(30) NOT NULL,

…> birthYear INT,

…> PRIMARY KEY (firstName, lastName)

…> );


sqlite> .quit


The last command (‘.quit’ for SQLite, ‘quit’ for MySQL) exits us from the SQL prompt

back to the operating-system prompt. With MySQL it would be the same except we would

probably need to specify a username and enter a password:

> mysql –u USERNAME –p PersonDb

Enter password:

… (information printed out by the program)

mysql> CREATE TABLE Person (

-> firstName VARCHAR(30) NOT NULL,

-> lastName VARCHAR(30) NOT NULL,

-> birthYear INT,

-> PRIMARY KEY (firstName, lastName)

-> );


mysql> quit

Here USERNAME should be replaced with the appropriate value. And the ‘-p’ flag tells

the  mysql  program  to  ask  for  a  password  before  SQL  commands  can  be  entered.

Alternatively,  and  this  is  the  normal  practice,  we  could  put  the  command  (or  more

generally,  commands)  into  a  file  and  run  this.  So  suppose  we  place  this  CREATE

command  in  a  file  called  createPersonTable.sql,  then  to  create  the  table  in  SQLite  we

would run:

> sqlite3 PersonDb < createPersonTable.sql

This just runs the script. It does not then leave you at the SQL prompt, but instead back

at the operating-system prompt. With MySQL it would be the same except for the issue of

the username and password:

> mysql –u USERNAME –p PersonDb < createPersonTable.sql




Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   300   301   302   303   304   305   306   307   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish