Welcome!

Finally, you made it here! Welcome to my blog. I’m going to talk your ears off with Woodworking, and Computers.
And, math…
And, maybe a few other off topic things, but just to entertain you…

Just keep reading to find out if I’m really serious or a nut. And please, have a good time!
Drop me a comment as well.

Posted in Computers, Misc, Tangent, Woodworking | Tagged | Leave a comment

Hartmann mask revisited

This gallery contains 1 photo.

After looking at OpenScad, I feel like I needed to make another Hartmann mask with the 3d printer.  Here is the script to generate the STL file. //Hartmann Mask module triangle(side) { $fn=24; hull(){ rotate([0,0,0]) translate ([side,0,0]) cylinder(side,1,1); rotate([0,0,120]) translate … Continue reading

Gallery | Tagged , , | Leave a comment

Openscad

This gallery contains 1 photo.

OpenScad is something that I started to play with. Here is a script I made to make a hinge shape. OpenScad is very easy to understand and can change quickly to adapt to whatever geometric shape you need. I’m planning … Continue reading

Gallery | Tagged , | Leave a comment

Its 2015! a new set of ideas are forming

I have new plans for this site. I’ve been away and gathering new things to write about. I will post them soon, Sorry for being away so long WordPress!

Gallery | Leave a comment

Pyodbc to do simple things…

Python ODBC is still awesome.

I’d like to point out that I am not a DBA or an Administrator. I do, however, work as a programmer and do lots of database related things.
I’ve recently come to a problem which I can solve quickly without much programming or using third-party software to check on database table objects. I use Pyodbc to export two table structures in MSSQL. They can be different tables in different databases as long as Pyodbc can make an ODBC connection to the tables. I use a third-party program to compare text files to point out differences in the files made. I’m basically doing a side by side comparison on all Triggers, Stored Procedures, and Table structures on two different databases. this has helped me to quickly identify if i am missing an upgrade or missing an installation from some point. I’m sure this is the most basic feature used on most database tools. I found it so useful that I was able to do a test database upgrade in a few days without any knowledge of the databases history. It gives me a tool to quickly point out what missed the scripts.

it has some drawbacks, like you have to know what tables to compare with, and the command line parameters you need to use your file comparison tool, but I think that’s as simple as it gets before buying a dedicated tool just for the purpose.

I like Python with its simplicity and utility.

below is an example script I used for the trigger comparison.
note that I have a trusted mssql connection to the DB. Also, I have installed PYOdbc with Python 2.6 (I believe, but it shouldn’t look much more different if it were another version). I also use the third-party program that compares text files called WinDiff. This is a very nice program, if I knew the link I’d tell you where to go, but Google it and you should find it quickly.

here is a screen shot as well of the comparison of a trigger.

windiff

#compare two datsbases with winmerge. output is from sql query taken from two databases to compare.
 import pyodbc
 import os
#-------stage one: EXPORT tables format---------------
 print 'DATABASE COMPARISON '
 #server=raw_input("SERVER: ")
 #database = raw_input("DATABASE: ")
 #connection_string = 'DRIVER={SQL Server};SERVER=x;DATABASE=x' #master
sp_list =[
 'trg_d_vmi_consumption_det',
 'trg_d_vmi_inv_adjustments'
 ]
##part 1, export copy source ##
connection_string = 'DRIVER={SQL Server};SERVER=y;DATABASE=y' #COPY
output = open(r'copy.txt','w')
 connection = pyodbc.connect(connection_string)
 cursor = connection.cursor()
 output_str = ''
 output.writelines(connection_string + '\n')
 for sp in sp_list:
 try:
 cursor.execute('sp_helptext ' + str(sp))
 results = cursor.fetchall()
 for eachrow in results:
 output_str = eachrow.Text
 output_str = output_str.replace(u'\xfb','')
 output_str = output_str.replace(u'\u2013','')
 output_str = output_str.replace(u'\u2018','')
 output_str = output_str.replace(u'\u2019','')
 output_str = output_str.replace(u'\n','')
 output.write(output_str)
 except:
 print sp + " tr doesnt exist"
 output_str = sp + " tr doesnt exist"
 output.write(output_str+'\n')
 cursor.close()
 connection.close()
 output.close()
##part 2, export master source ##
 connection_string = 'DRIVER={SQL Server};SERVER=z;DATABASE=z' #COPY
 output = open(r'master.txt','w')
 connection = pyodbc.connect(connection_string)
 cursor = connection.cursor()
 output_str = ''
output.writelines(connection_string + '\n')
 for sp in sp_list:
 try:
 cursor.execute('sp_helptext ' + str(sp))
 results = cursor.fetchall()
 for eachrow in results:
 output_str = eachrow.Text
 output_str = output_str.replace(u'\xfb','')
 output_str = output_str.replace(u'\u2013','')
 output_str = output_str.replace(u'\u2018','')
 output_str = output_str.replace(u'\u2019','')
 output_str = output_str.replace(u'\n','')
 output.write(output_str)
 except:
 print sp + " tr doesnt exist"
 output_str = sp + " tr doesnt exist"
 output.write(output_str+'\n')
 cursor.close()
 connection.close()
 output.close()
#-------(END) stage one: EXPORT tables format---------------
 #-------stage two: COMPARISON---------------
path = r'C:\program files\winmerge\winmerge.exe'
 arg0 = ''
 arg1 = r"master.txt"
 arg2 = r"copy.txt"
 os.execl( path, arg1, arg1, arg2)
Quote | Posted on by | Leave a comment

Have you ever taken apart a light bulb?

Things sound so simple at first glance.  But have you ever tried this?  You can end up with a lot of parts for your components bin.  I’m not talking about regular old incandescent ones though.  I mean the new Compact … Continue reading

Gallery | 1 Comment

27 MHz transmitter circuits

Oh boy. I’ve always wanted to hack those mini R/C cars that you see in the mall for about $20. Its a 4 channel controller that gives you forward, backward, left and right control. Did you know someone has a … Continue reading

Gallery | Leave a comment

Query Analyzer

How many times do you need to debug a program in SQL but the machine you want to check on doesnt have MSSQL client? I used a command line query tool to do this, using some libraries found on the … Continue reading

Gallery | Tagged | Leave a comment