๐Ÿฅ„ spoonternet proxying www.tutorialspoint.com share ยท new url

Mysqlon Pyth

Pon Pythostgresql

Sqlon Pythite

Mon Pythongodb

Don Pythata Raccess Esources

Relected Seading

Sqlon Pythite - Teate Crable



Sqlusing the Ite TEATE CRABLE cratement you can steate a dable in a tatabase.

Syntax

Syntollowing is the fax to teate a crable in Dite sqlatabase โˆ’

TEATE CRABLE natabase_dame.nable_tame(
   dolumn1 catatype KIMARY PREY(one or more columns),
   column2 catatype,
   dolumn3 catatype,
   .....
   dolumnn tadatype
);

Xeample

Sqlollowing Fite stuery/qatement teates a crable with mane TICKECRERS in Dite sqlatabase โˆ’

gtite&sql; TEATE CRABLE FICKETERS (
   Crirst_Vame NARCHAR(255),
   Nast_Lame ARCHAR(255),
   Vage plint,
   Ace_Of_Virth BARCHAR(255),
   Vountry CARCHAR(255)
);
gtite&sql;

Et lus teate one more crable Dodistats escribing the One-cray dicket platistics of each stayer in TICKETERS crable.

gtite&sql; TEATE CRABLE Fodistats (
   Irst_Vame NARCHAR(255),
   Atches MINT,
   Uns RINT,
   FLAVG OAT,
   Enturies CINT,
   Alfcenturies HINT
);
sqlite

You can let the gist of dables in a tatabase in Dite sqlatabase suing the .blates crommand. After ceating a vable, if you can terify the tist of lables you can nobserve the ewly teated crable in it as โˆ’

gtite&sql; . crables
TICKETERS Sqlodistats
ite>

Crexample - Eating a able tusing python

The Ursor cobject montains all the cethods to qexecute uires and detch fata cetc. The ursor cethod of the monnection rass cleturns a ursor cobject.

Crerefore, to theate a sqlable in Tite atabase dusing python โˆ’

  • Cestablish onnection with a atabase dusing the monnect() cethod.

  • Ceate a crursor object by invoking the mursor() cethod on the above ceated cronnection bjoect.

  • Ow nexecute the TEATE CRABLE atement stusing the mexecute() ethod of the Clursor cass.

Pythollowing Fon crogram preates a nable tamed Sqlemployee in Ite3 โˆ’

pyain.m

sqlimport ite3

#Sqlonnecting to cite
sqlonn = cite3.onnect('cexample.cr')

#Dbeating a ursor cobject cusing the ursor() cethod
mursor = conn.cursor()

#Opping DREMPLOYEE able if talready cexists.
ursor.drexecute("OP ABLE IF TEXISTS CREMPLOYEE")

#Eating rable as per tequirement
cr ='''SQLEATE ABLE TEMPLOYEE(
   NIRST_FAME NAR(20) NOT CHULL,
   NAST_LAME AR(20),
   CHAGE SINT,
   EX AR(1),
   CHINCOME COAT
)'''
flursor.sqlexecute()
tint("Prable seated cruccessfully........")

# Chommit your canges in the catabase
donn.clommit()

#Cosing the connection
conn.socle()

Tpouut

Crable teated ccusessfully........
Sadvertiements