Contact:

slinkworks@gmail.com

Tuesday, January 10, 2012

Extracting Data From Gun Log Database

Warning: Do this at your own risk! Seriously, don't ruin your data!

The Gun Log database can be copied via iTunes file sharing.

Once you have copied the database, do not take the copy and over write the original database by copying it back using iTunes file sharing.

The database is called Shooting_Buddy.sqlite.

Open the database with an SQLite database explorer. SQLManager for the Firefox web browser works just fine.

Use this query to see the weapon entries:

SELECT
W.ZMAKE as Make,
W.ZMODEL as Model,
W.ZCALIBER as Caliber,
W.ZNAME as [Nick Name],
W.ZSERIALNUMBER as [Serial Number],
W.ZNOTES as [Weapon Notes],
datetime(P.ZPURCHASEDATE,'unixepoch', '+31 years', '+1 days') as [Purchase Date],
P.ZPRICE as [Purchase Price],
P.ZSELLER as Seller,
P.ZNOTES as [Purchase Notes],
S.ZBUYER as [Buyer],
S.ZPRICE as [Sale Price],
datetime(S.ZSELLDATE,'unixepoch', '+31 years', '+1 days') as [Sale Date],
S.ZNOTES as [Sale Notes]

FROM ZWEAPON AS W
LEFT OUTER JOIN ZWEAPONPURCHASEINFO AS P
ON W.Z_PK = P.ZWEAPON
LEFT OUTER JOIN ZWEAPONSALEINFO AS S
ON W.Z_PK = S.ZWEAPON

Use this query to see the accessory entries:

SELECT
A.ZDESCRIPTION as Description,
A.ZNOTES as Notes,
A.ZSERIALNUMBER as [Serial Number], 
datetime(P.ZPURCHASEDATE,'unixepoch', '+31 years', '+1 days') as [Purchase Date],
P.ZPRICE as [Purchase Price],
P.ZSELLER as Seller,
P.ZNOTES as [Purchase Notes],
S.ZBUYER as [Buyer],
S.ZPRICE as [Sale Price],
datetime(S.ZSELLDATE,'unixepoch', '+31 years', '+1 days') as [Sale Date],
S.ZNOTES as [Sale Notes]

FROM ZACCESSORY AS A
LEFT OUTER JOIN ZACCESSORYPURCHASEINFO AS P
ON A.Z_PK = P.ZACCESSORY
LEFT OUTER JOIN ZACCESSORYSALEINFO AS S
ON A.Z_PK = S.ZACCESSORY

Through SQLManager you can export the results to a CSV file.

Remember, do not copy the database back! You can easily mess up the database and lose information, corrupt the data, or even crash Gun Log.

No comments:

Post a Comment