Muhammad Al Xorazmiy nomidagi Toshkent Axborot texnologiyalari


Download 21.52 Kb.
Sana17.06.2023
Hajmi21.52 Kb.
#1549192




Muhammad Al - Xorazmiy nomidagi

Toshkent Axborot texnologiyalari

Universiteti

Fakultet: Dasturiy Injiniring

Guruh: 312 - 20

Fan: Mobil ilovalarni ishlab chiqarish

Topshirdi: Toshpulatov Samandarbek


Sayohat dasturi - diqqatga sazovor joylar, turar joy va transport chiptalarini bron qilish, shuningdek, marshrutni rejalashtirish haqida ma'lumot beradi

swift dasturlash tilida
1.SQLite kutubxonasi yuklash:

Siz SQLite kutubxonasi bilan ishlatishingiz mumkin. SQLite kutubxonasini o'rnatish uchun CocoaPods yoki boshqa tizimlardan foydalana olasiz.


2.Bazani ochish:


var db: OpaquePointer?


guard let filePath = Bundle.main.path(forResource: "sayohat", ofType: "sqlite") else {


print("Database file not found")
return
}

if sqlite3_open(filePath, &db) != SQLITE_OK {


print("Error opening database")
return
}

3.Diqqatga sazovor joylar haqida ma'lumot olish:


let query = "SELECT * FROM hotels WHERE location = 'Diqqatga sazovor'"

var statement: OpaquePointer?


guard sqlite3_prepare_v2(db, query, -1, &statement, nil) == SQLITE_OK else {


print("Error preparing select statement")
return
}

while sqlite3_step(statement) == SQLITE_ROW {


let id = sqlite3_column_int(statement, 0)
let name = String(cString: sqlite3_column_text(statement, 1))
let location = String(cString: sqlite3_column_text(statement, 2))
let price = sqlite3_column_double(statement, 3)
print("\(id) - \(name) - \(location) - \(price)")
}

sqlite3_finalize(statement)


4.Turar joylar haqida ma'lumot olish:


let query = "SELECT * FROM sights WHERE city = 'Tashkent' AND type = 'Historical'"

var statement: OpaquePointer?


guard sqlite3_prepare_v2(db, query, -1, &statement, nil) == SQLITE_OK else {


print("Error preparing select statement")
return
}

while sqlite3_step(statement) == SQLITE_ROW {


let id = sqlite3_column_int(statement, 0)
let name = String(cString: sqlite3_column_text(statement, 1))
let city = String(cString: sqlite3_column_text(statement, 2))
let type = String(cString: sqlite3_column_text(statement, 3))
let description = String(cString: sqlite3_column_text(statement, 4))
print("\(id) - \(name) - \(city) - \(type) - \(description)")
}

sqlite3_finalize(statement)




Download 21.52 Kb.

Do'stlaringiz bilan baham:




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