336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

http://raspberrywebserver.com/sql-databases/using-mysql-on-a-raspberry-pi.html

Mysql_Download_Site ☜

다운받기

MyWebSQL(웹에서 사용할때)


mywebsql-3.6.zip

mysql-5.6.26-win32 >> bin >> mysql_upgrade 클릭

>>mysql클릭


show databases; 라고 typing 해보면




=====================================

Using Mysql on a Raspberry PI

SQLite is a great database for many situations,

but there are times when it's not quite up to the job.

SQLite can be used in web sites, 

but it's much more common to use MySQL. This is because


●MySQL is more scalable,

●MySQL can be tuned more easily,

●it supports user management and permissions,

●MySQL is better for sites with heavy traffic,

●it can be used in client server architectures 

where a database client must access a database remotely.

사용될수있다. in 클라이언트 서버 구조에서

where a DB 클라이언트가 반드시 접속해야하는 a database에 원격으로.


>>

Setting up MySQL on a Raspberry Pi

Before we get started, 

we need to install MySQL server and the Python bindings for MySQL:

설치해야만하는 필수 프로그램들

sudo apt-get install mysql-server python-mysqldb

During the installation of MySQL server, 

you will be prompted to enter a password for the MySQL root account.

설치동안 of MySQL server를,

넌 will be 제촉하게된다. to enter하기위해 PW를 for the MySQL root account를위해

I'm going to create a database to log temperatures as I did with the SQLite posts. 

(▼항목추가하기(=CREATE database ??;), 확인하기(SHOW databases;))


As before, I'm going to create a database named temps to store records with fields for a date, time, zone and temperature.

Like SQLite, 

MySQL comes with a shell that can be used for configuration. 

We can use the the MySQL shell to create a database:

$ mysql -u root -p Enter password: mysql> CREATE DATABASE temps mysql> USE temps

The 'USE temps' command tells the shell to use that database 

in future operations in this shell session.



MySQL supports users accounts, 

so we need to create a database user and give it access to the database:

암호넣고 로그인후 아래 3줄을 타이핑하면된다.(대,소문자 구분)

mysql> CREATE USER 'monitor'@'localhost' IDENTIFIED BY 'password'; mysql> GRANT ALL PRIVILEGES ON temps.* TO 'monitor'@'localhost' mysql> FLUSH PRIVILEGES; mysql> quit



This creates a user called monitor (because the database is going to be accessed by a program that monitors temperatures), and assigns it a pass word 'password'. This user is allowed to connect to the database from 'localhost'.

Initially, the new user has no privileges

so it must be granted some access rights using the 'GRANT' command. 

권한없음, so 부여되야만한다. some 접근권한이 ('GRANT'라고 타이핑할것)

I have used 'ALL' in this example, 

but in real world applications 

it would be better to grant users more limited rights. 

A complete list of privilege options is available athttp://dev.mysql.com/doc/refman/5.1/en/grant.html.

The last command quits the shell so that we can re-enter the shell as the user that we just created:


mysql -u monitor -p

Now I'm going to create a table with the fields needed for storing data:

CREATE TABLE tempdat (tdate DATE, ttime TIME, zone TEXT, temperature NUMERIC);

Accessing a MySQL database with Python

I'm going to use Python to populate the database. As in the previous examples, I'm going to create sample data from one day ago, 12 hours ago and now, and I'm going to record temperatures in three different zones.

This Python code is the start of my script:


#!/usr/bin/env python import MySQLdb db = MySQLdb.connect("localhost", "monitor", "password", "temps") curs=db.cursor()
I imported the MySQLdb python module and connected to it with the user name and password that I set up in the shell. The following code then inserts records into the database:

# note that I'm using triplle quotes for formatting purposes # you can use one set of double quotes if you put the whole string on one line try: curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE() - INTERVAL 1 DAY, NOW(), 'kitchen', 21.7)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE() - INTERVAL 1 DAY, NOW(), 'greenhouse', 24.5)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE() - INTERVAL 1 DAY, NOW(), 'garage', 18.1)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW() - INTERVAL 12 HOUR, 'kitchen', 20.6)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW() - INTERVAL 12 HOUR, 'greenhouse', 17.1)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW() - INTERVAL 12 HOUR, 'garage', 16.2)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW(), 'kitchen', 22.9)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW(), 'greenhouse', 25.7)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW(), 'garage', 18.2)""") db.commit() print "Data committed" except: print "Error: the database is being rolled back" db.rollback()
If there's an error during any of these SQL commands, or if there's an error while committing the changes, the changes will be rolled back. This can be simplified using a Python context manager:

with db: curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE() - INTERVAL 1 DAY, NOW(), 'kitchen', 21.7)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE() - INTERVAL 1 DAY, NOW(), 'greenhouse', 24.5)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE() - INTERVAL 1 DAY, NOW(), 'garage', 18.1)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW() - INTERVAL 12 HOUR, 'kitchen', 20.6)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW() - INTERVAL 12 HOUR, 'greenhouse', 17.1)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW() - INTERVAL 12 HOUR, 'garage', 16.2)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW(), 'kitchen', 22.9)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW(), 'greenhouse', 25.7)""") curs.execute ("""INSERT INTO tempdat values(CURRENT_DATE(), NOW(), 'garage', 18.2)""")

This will automatically handle commit and rollback operations.

Getting data from the database

Once data has been inserted into the database, we need to be able to retrieve it. We can do this using the SQL select command. The execute function runs the SQL query, and the fetchall function returns a list of records that matched the query:

curs.execute ("SELECT * FROM tempdat") print "\nDate Time Zone Temperature" print "===========================================================" for reading in curs.fetchall(): print str(reading[0])+" "+str(reading[1])+" "+\ reading[2]+" "+str(reading[3])

The for loop iterates through the list of results. Each record is a list of values. Note that the time and the temperature values have to be converted to a string before they can be appended to the result string. This code prints the contents of the entire database as a table:
Date Time Zone Temperature =========================================================== 2013-09-09 14:41:46 kitchen 21.7 2013-09-09 14:41:46 greenhouse 24.5 2013-09-09 14:41:46 garage 18.1 2013-09-10 2:41:46 kitchen 20.6 2013-09-10 2:41:46 greenhouse 17.1 2013-09-10 2:41:46 garage 16.2 2013-09-10 14:41:46 kitchen 22.9 2013-09-10 14:41:46 greenhouse 25.7 2013-09-10 14:41:46 garage 18.2

We can use the WHERE keyword to attach conditions to a query. In this example, I'm going to search for records where the temperature is above 20.0 degrees:

curs.execute ("SELECT * FROM tempdat WHERE temp>%s", (str(20.0),))

Note that it's important not to use string substitution to insert parameters into the query as this makes it easier for people to inject malicious SQL code into a query. This query does the same thing, but it's less secure:

curs.execute ("SELECT * FROM tempdat WHERE temp>%s" % str(20.0))

In this example, the variable is unconditionally inserted into the query. In the previous one, the query and the parameter are passed to the MySQL library, which checks to see if the parameter is safe before inserting it.

The output from this query is

Date Time Zone Temperature =========================================================== 2013-09-09 14:41:46 kitchen 21.7 2013-09-09 14:41:46 greenhouse 24.5 2013-09-10 2:41:46 kitchen 20.6 2013-09-10 14:41:46 kitchen 22.9 2013-09-10 14:41:46 greenhouse 25.7

At the end of the script, we close the connection to the database:

db.close()

See also: http://dev.mysql.com/doc/refman/5.5/en/sql-syntax.html.


라즈베리파이 DB

EngineeringGarage


wget https://cayenne.mydevices.com/dl/rpi_w666zd5hsi.h

sudo bash rpi_w666zd5hsi.sh -v

Posted by ElectricShock
:
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

http://www.picmicrolab.com/7x5-dot-matrix-character-generator/





Consider the following definitions in an assembly program

d1: .byte 0, 1, 2, 3

and assume that the following instructions are used to add the content of the last two numbers and leave the result in R12

1 ?

2. LDD R12, Y + 2

3 LDD R13, Y + 3

4 ADD R12, R13

R12에 Load하고 R13에 Load하고 R12+R13 이렇게 ADD연산

What instruction would you add at the first position of this block to perform the correct operation ?

Two instructions LDI R29, lo8(d1) and LD R28, hi8(d1)






if we use sequences of 8 bits, how many unique binary sequences can we encode?

만약 사용하면 시퀀스를 of 8bit, 얼마나많은 유니크 2진수 시퀀스를 can 우리가 만들수 있는가?

2^8 = 256


which of the following nunbers cannot be a number in base 6 ?

어느것... of 따라오는 숫자들의 ...이 cannot be a 숫자가될수없는가 in base 6 ? (6진수)

1701 <<< 6이상의 숫자가 들어가면 안됨 (6포함)


Study the folowing 9 bit integer encoded using sign-magnitude:

알아봐라 the 따라오는 9bit 정수 인코드된 사용하여 sign-mangnitude(=부호있는)

011000110

Convert this to decimal

2^7+2^6+2^2+2^1 = 128+64+4+2 = 198


Study the following 9 bit number 011010001

The number format is fixed-point with 4 bit integer,

5-bit fraction, unsigned.

Convert this to decimal. Use as many decimal places as necessary

알아봐라. the 따라오는 9bit number 011010001

the 숫자 포멧은 fixed-point이다. with 4bit 정수로된,

5-bit는 fraction(=분수), unsigned(=부호없음).

변형시켜라. 이걸 to 10진수로. 사용해라. as many 10진수 자리들을 as 필요하다면


0110 = 2^2+2^1 = 6

1001 = 2^-1 + 2^-4 = 0.5625

=6.5625


Study the following 7 bit number:

0001100

The number format is floating-point with 1 sign bit, 2 exponent bits, 4 mantissa bits.

The exponent is signed with a bias of -1.

There is no implicit one for the mantissa in the encoding (0,mantissa)

Convert this to decimal, use as many decimal places as necessary.

알아봐라 the 따라오는 7bit 숫자를

0001100

the숫자포멧은 floating point with 1 sign bit,

2 exponent bits, (=지수부)

4 mantissa bits. (=소수점아래)

the exponent는 부호가붙었다. with a bias of -1.

there is No 절대적인 one은 없다. for the mantissa를 위한 in the 인코딩에서

바꿔라 이걸 to 10진수로.




Posted by ElectricShock
:
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

'T > TV프로그램' 카테고리의 다른 글

선다방  (0) 2019.06.19
김비서가 왜 그럴까  (0) 2018.06.14
KBS :: 1대100 촬영대본 (비공개) (이름나옴)  (0) 2016.01.07
Posted by ElectricShock
:

BLOG main image
잡동사니들(지극히 개인취향인...) (다른글에도 댓글 부탁해요♥) You May Leave English Messages on GuestBook. by ElectricShock

공지사항

카테고리

분류 전체보기 (782)
MiDi (2)
Programming(=프로그래밍) (3)
Animation (4)
Blender (3D Graphic Program.. (10)
Blendtuts.com (Series) (1)
Blender 기초 팁들 (2)
Processing (디지털미디어과) (2)
Music (1)
Books in the world (0)
Communication(CAN, UART, et.. (12)
MCU Examples (PIC 기반) (7)
Transistor (1)
Mikro C Pro (11)
Mikro Pascal (1)
Proton IDE (0)
Robot (0)
Swift 3D (1)
Dummies Series (1)
All about Hacking (0)
제2 외국어 (1)
PIC 해외서적들 (3)
AVR (25)
PIC (MikroC) (MPLAB) (4)
Assembly (2)
ARM (3)
Arduino (26)
PSpice (1)
Proteus ISIS (14)
CodeVision (2)
FPGA (15)
MPLAB (24)
PCB (the Procedure) (15)
3D Printer (5)
PICKIT3 (6)
Matlab (11)
RaspBerry PI (15)
BeagleBone (1)
Android Studio (17)
졸업작품 (172)
Korea History (0)
Issue(사회) (73)
Multimeter 리뷰 (1)
Oscilloscope (1)
A (34)
B (19)
J (6)
C (32)
P (12)
T (37)
H (12)
I (12)
M (44)
R (5)
E (5)
F (2)
D (9)
O (2)
L (7)
S (9)
W (2)
V (6)
G (14)
Visual C++ or Visual Studio (2)
Android App Development (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백