Home Database Mysql Tutorial sqlite入门练习,通讯录增删改查

sqlite入门练习,通讯录增删改查

Jun 07, 2016 pm 02:57 PM
sqlite getting Started practise choose Address book

选择了sqlite作为sql语言入门练习的数据库,因而也选择了同样轻便的编程工具AAuto,其封装了sqlite库,方便好用且很快写出一个带界面的小工具,有兴趣的OSC友只需到官网下载快手开发工具,解压缩,新建工程运行以下代码即可看到效果。 透过编写这个工具了解及

  选择了sqlite作为sql语言入门练习的数据库, 因而也选择了同样轻便的编程工具AAuto ,其封装了sqlite 库,方便好用且很快写出一个带界面的小工具 ,有兴趣的OSC友只需到官网下载快手开发工具,解压缩,新建工程运行以下代码即可看到效果。

透过编写这个工具了解及学习了以下知识:
1.sql基本语言, sqlite数据库创建、数据增加、修改、删除及模糊查询,命名参数运用。
2.列表视图listview控件的简单操作运用。
3.windows控件、窗体的命令响应、通知,消息循环等知识。
4.aauto的编程语言的数据类型、名字空间等特点。


        SQLite AAuto Quicker            

       

                                                sqlite入门练习,通讯录增删改查                                                                        

import win.ui;
import crreaDb;
/*DSG{{*/
var winform = ..win.form(text="快手通讯录   by 菲菲OSC";right=558;bottom=427;parent=...)
winform.add(
button={cls="button";text="添加记录";left=19;top=19;right=100;bottom=48;z=1};
button2={cls="button";text="编辑记录";left=115;top=19;right=196;bottom=48;z=2};
button3={cls="button";text="删除记录";left=211;top=19;right=292;bottom=48;z=3};
button4={cls="button";text="查找";left=476;top=22;right=536;bottom=48;z=5};
dress={cls="edit";left=375;top=152;right=541;bottom=176;edge=1;z=9};
edit={cls="edit";text="输入查找条件...";left=318;top=21;right=457;bottom=48;edge=1;z=4};
emal={cls="edit";left=375;top=193;right=541;bottom=217;edge=1;z=10};
listview={cls="listview";left=19;top=69;right=292;bottom=408;bgcolor=16777215;edge=1;fullRow=1;z=6};
mark={cls="richedit";text="备注";left=313;top=280;right=543;bottom=408;edge=1;hscroll=1;multiline=1;vscroll=1;z=17};
name={cls="edit";left=375;top=71;right=541;bottom=95;edge=1;z=7};
qq={cls="edit";left=375;top=234;right=541;bottom=258;edge=1;z=11};
static={cls="static";text="姓名";left=319;top=69;right=359;bottom=93;transparent=1;z=12};
static2={cls="static";text="电话";left=319;top=110;right=359;bottom=134;transparent=1;z=13};
static3={cls="static";text="地址";left=319;top=152;right=359;bottom=176;transparent=1;z=14};
static4={cls="static";text="邮箱";left=319;top=193;right=359;bottom=217;transparent=1;z=15};
static5={cls="static";text="QQ/MSN";left=319;top=234;right=359;bottom=258;transparent=1;z=16};
tel={cls="edit";left=375;top=112;right=541;bottom=136;edge=1;z=8}
)
/*}}*/

var sqlConnection = sqlite("\res\contact.db")
crreaDb.careaTable(sqlConnection)

// 显示数据
var showData = function(sql){
	for id,姓名,电话, 地址,邮箱,QQ ,备注 in sqlConnection.each("select rowid,* from tl") {
		winform.listview.addItem({tostring(id);姓名;电话; 地址;邮箱;QQ;备注})  	
	}
}

winform.listview.insertColumn("id",1)
winform.listview.insertColumn("姓名",100)
winform.listview.insertColumn("电话",100)
winform.listview.insertColumn("地址",120)
winform.listview.insertColumn("邮箱",120)
winform.listview.insertColumn("QQ",80)
winform.listview.insertColumn("备注",150)
showData()
winform.show() 

winform.button.oncommand = function(id,event){
	// 添加
	var name = winform.name.text
	var tel = winform.tel.text
	var dress = winform.dress.text
	var em = winform.emal.text
	var qq = winform.qq.text
	var mark = winform.mark.text
	crreaDb.addData(sqlConnection,name,tel,dress,em,qq,mark)
	id = sqlConnection.lastInsertRowid()
	var data = sqlConnection.stepQuery("select rowid,* from [tl] where rowid = "+id)
	winform.listview.addItem({tostring(data.id);data.name;data.tel;data.dress;data.em;data.qq;data.mark})
}

winform.button3.oncommand = function(id,event){
	// 删除
	var coun = winform.listview.selIndex
	var id = winform.listview.getItemText(coun)
	if(id){
		crreaDb.delData(sqlConnection,id)	
		winform.listview.clear()
		showData()		
		winform.listview.selIndex = coun	
	}
	else {
		winform.msgbox("请选择要删除的列")
	}
}


winform.button2.oncommand = function(id,event){
	// 编辑修改
	crreaDb.editData(sqlConnection,name,tel,dress,em,qq,mark,id)	
}


winform.button4.oncommand = function(id,event){
	// 查询
	var vv = winform.edit.text
	var id = crreaDb.inQuiry(sqlConnection,vv)
	winform.listview.clear()
	if(id){		
		for(i=1;#id;1){
			winform.listview.addItem({tostring(id[i].rowid);id[i].name;id[i].tel; id[i].dress;id[i].em;id[i].qq;id[i].mark})	
		}
	}
	else {
		winform.msgbox("找不到记录")
	}
}

winform.edit.wndproc = function(hwnd,message,wParam,lParam){
	if( message = 0x202/*_WM_LBUTTONUP*/ ) winform.edit.text = ""
}

winform.listview.onnotify = function(id,code,ptr){
	select(code) {
		case 0xFFFFFF9B/*_LVN_ITEMCHANGED*/  {
			if(winform.listview.selIndex){
				var lvw = winform.listview				
				winform.name.text = lvw.getItemText(lvw.selIndex,2)
				winform.tel.text = lvw.getItemText(lvw.selIndex,3)
				winform.dress.text = lvw.getItemText(lvw.selIndex,4)
				winform.emal.text = lvw.getItemText(lvw.selIndex,5)
				winform.qq.text = lvw.getItemText(lvw.selIndex,6)
				winform.mark.tex = lvw.getItemText(lvw.selIndex,7)
			}
		}
	}
}

win.loopMessage();
sqlConnection.exec("VACUUM")
sqlConnection.close()
return winform;
Copy after login

namespace crreaDb;
import sqlite;

careaTable = function(db){
	if( not db.existsTable("tl") ){
	//创建表
		db.exec( "create table tl(
			name, 
			tel , 
			dress,
			em,
			qq ,
			mark
			);"
		)
	}
}

// 添加数据
addData = function(db,name,tell,dress,em,qq,mark){
	var command = db.prepare("insert into [tl] values ( @name,@tel,@dress,@em,@qq,@mark );" ) 
	command.bind.parameterAtNames(  
	   	name = name;
		tel = tell;
		dress = dress;
		em = em;
		qq = qq;
		mark = mark
	).step() 
	command.finalize()	
}


// 删除
delData = function(db,id){
	db.exec("DELETE FROM [%s] where rowid=%d;","tl",id)
}


// 修改
editData = function(db,name,tel,dress,em,qq,mark,id){
	db.exec("UPDATE [tl] SET name = @name,tel=@te1 ,dress=@dress,em=@em,QQ=@qq,mark=@mark WHERE rowid = @id;",{
    	name = name;
		tel = tel;
		dress = dress;
		em = em;
		qq = qq;
		mark = mark;
		id = id    
	});				
}


// 模糊查询
inQuiry = function(db,re){
	var tab = db.getTable("select rowid,* from [tl] where ifnull(name,'') || ifnull(tel,'') || ifnull(QQ,'') like '%"+ re+ "%'")
	return  tab
}
Copy after login

                               

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

A Diffusion Model Tutorial Worth Your Time, from Purdue University A Diffusion Model Tutorial Worth Your Time, from Purdue University Apr 07, 2024 am 09:01 AM

Diffusion can not only imitate better, but also "create". The diffusion model (DiffusionModel) is an image generation model. Compared with the well-known algorithms such as GAN and VAE in the field of AI, the diffusion model takes a different approach. Its main idea is a process of first adding noise to the image and then gradually denoising it. How to denoise and restore the original image is the core part of the algorithm. The final algorithm is able to generate an image from a random noisy image. In recent years, the phenomenal growth of generative AI has enabled many exciting applications in text-to-image generation, video generation, and more. The basic principle behind these generative tools is the concept of diffusion, a special sampling mechanism that overcomes the limitations of previous methods.

Can wallpaper engine be shared among families? Can wallpaper engine be shared among families? Mar 18, 2024 pm 07:28 PM

Does Wallpaper support family sharing? Unfortunately, it cannot be supported. Still, we have solutions. For example, you can purchase with a small account or download the software and wallpapers from a large account first, and then change to the small account. Simply launching the software is perfectly fine. Can wallpaperengine be family shared? Answer: Wallpaper does not currently support the family sharing function. 1. It is understood that WallpaperEngine does not seem to be suitable for family sharing environments. 2. In order to solve this problem, it is recommended that you consider purchasing a new account; 3. Or download the required software and wallpapers in the main account first, and then switch to other accounts. 4. Just open the software with a light click and it will be fine. 5. You can view the properties on the above web page"

Generate PPT with one click! Kimi: Let the 'PPT migrant workers' become popular first Generate PPT with one click! Kimi: Let the 'PPT migrant workers' become popular first Aug 01, 2024 pm 03:28 PM

Kimi: In just one sentence, in just ten seconds, a PPT will be ready. PPT is so annoying! To hold a meeting, you need to have a PPT; to write a weekly report, you need to have a PPT; to make an investment, you need to show a PPT; even when you accuse someone of cheating, you have to send a PPT. College is more like studying a PPT major. You watch PPT in class and do PPT after class. Perhaps, when Dennis Austin invented PPT 37 years ago, he did not expect that one day PPT would become so widespread. Talking about our hard experience of making PPT brings tears to our eyes. "It took three months to make a PPT of more than 20 pages, and I revised it dozens of times. I felt like vomiting when I saw the PPT." "At my peak, I did five PPTs a day, and even my breathing was PPT." If you have an impromptu meeting, you should do it

How to set lock screen wallpaper on wallpaper engine? How to use wallpaper engine How to set lock screen wallpaper on wallpaper engine? How to use wallpaper engine Mar 13, 2024 pm 08:07 PM

WallpaperEngine is a software commonly used to set desktop wallpapers. Users can search for their favorite pictures in WallpaperEngine to generate desktop wallpapers. It also supports adding pictures from the computer to WallpaperEngine to set them as computer wallpapers. Let’s take a look at how wallpaperengine sets the lock screen wallpaper. Wallpaperengine setting lock screen wallpaper tutorial 1. First enter the software, then select installed, and click "Configure Wallpaper Options". 2. After selecting the wallpaper in separate settings, you need to click OK on the lower right. 3. Then click on the settings and preview above. 4. Next

How to practice typing with Kingsoft Typing Guide - How to practice typing with Kingsoft Typing Guide How to practice typing with Kingsoft Typing Guide - How to practice typing with Kingsoft Typing Guide Mar 18, 2024 pm 04:25 PM

Nowadays, many friends like to use Kingsoft Typing Assistant, but the typing speed seriously affects work efficiency, so I teach you to practice typing speed. So how to use Kingsoft Typing Assistant to practice typing? Today, the editor will give you a tutorial on how to practice typing numbers with Kingsoft Typing Assistant. The following is described, I hope it will be helpful to everyone. First, open the Kingsoft typing software, then click the (Getting Started) button with your mouse, then click the (Number Keys) button in a new window, then click the (Start from Scratch) button below to practice, or click the (Test Mode) button. , just enter numbers for practice. In addition, Kingsoft Typing Assistant has other functions that can help you practice typing better. 1. Select practice mode: On the software interface, you can see that there are different practice modes, such as "New

Is there any virus when watching wallpaper engine movies? Is there any virus when watching wallpaper engine movies? Mar 18, 2024 pm 07:28 PM

Users can download various wallpapers when using WallpaperEngine, and can also use dynamic wallpapers. Many users do not know whether there are viruses when watching videos on WallpaperEngine, but video files cannot be used as viruses. Is there any virus when watching movies on wallpaperengine? Answer: No. 1. Just video files cannot be used as viruses. 2. Just make sure to download videos from trusted sources and maintain computer security measures to avoid the risk of virus infection. 3. Application wallpapers are in apk format, and apk may carry Trojan viruses. 4. WallpaperEngine itself does not have viruses, but some application wallpapers in the creative workshop may have viruses.

All CVPR 2024 awards announced! Nearly 10,000 people attended the conference offline, and a Chinese researcher from Google won the best paper award All CVPR 2024 awards announced! Nearly 10,000 people attended the conference offline, and a Chinese researcher from Google won the best paper award Jun 20, 2024 pm 05:43 PM

In the early morning of June 20th, Beijing time, CVPR2024, the top international computer vision conference held in Seattle, officially announced the best paper and other awards. This year, a total of 10 papers won awards, including 2 best papers and 2 best student papers. In addition, there were 2 best paper nominations and 4 best student paper nominations. The top conference in the field of computer vision (CV) is CVPR, which attracts a large number of research institutions and universities every year. According to statistics, a total of 11,532 papers were submitted this year, and 2,719 were accepted, with an acceptance rate of 23.6%. According to Georgia Institute of Technology’s statistical analysis of CVPR2024 data, from the perspective of research topics, the largest number of papers is image and video synthesis and generation (Imageandvideosyn

In which folder are the wallpapers of wallpaper engine located? In which folder are the wallpapers of wallpaper engine located? Mar 19, 2024 am 08:16 AM

When using wallpaper, users can download various wallpapers they like for use. Many users do not know which folder the wallpapers are in. The wallpapers downloaded by users are stored in the content folder. Which folder is the wallpaper in? Answer: content folder. 1. Open File Explorer. 2. Click "This PC" on the left. 3. Find the "STEAM" folder. 4. Select "steamapps". 5. Click “workshop”. 6. Find the “content” folder.

See all articles