Tag: syndicated

  • Python and Tweepy

    One of the projects that’s been on my list lately is to programmatically access Twitter for a few ideas I want to play with. Since I’ve been trying to learn some Python, I thought I would take a look using Python to update status and read status.

    A quick Google search showed me lots of Python clients, but Tweepy caught my eye for some reason. I’m not sure why, but I ended up popping a command line open and downloading the library.

    From there, I saw a short tutorial over at Python Central. I started by creating an app at Twitter for myself, which was very simple. Once that was done, I had a set of consumer tokens (key and secret), that I could use. Another click got me to the access key and secret. Note, the easy way to do this is over at dev.twitter.com.

    My first attempt was using this sample code.

    import tweepy

    consumer_key = “ABCDE”
    consumer_secret = “12345”
    access_token = ‘asdfasdf’
    access_token_secret = ‘98765’

    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)

    api = tweepy.API(auth)

    public_tweets = api.user_timeline()
    for tweet in public_tweets:
    print(tweet.text)

    This gives me a list of my tweets. At least, the last 20.

    2015-11-06 13_30_24-SDTIG - [C__Users_Steve_OneDrive_Documents_Python_SDTIG] - ..._Last_10_twitter_l

    That’s progress.

    I then went to make an update by using this:

    api.update_status('Hello, Pyton')

    However that returned an error:

    2015-11-06 13_50_53-Cortana

    Hmmm, I double checked the API, and this should work, but I’m guessing there’s another issue. I searched, and found there’s a bug. However, I should be using named parameters, so no big deal. Change the code.

    api.update_status(status='Hello, Pyton')

    Now it works.

    2015-11-06 13_53_06-Steve Jones (@way0utwest) _ Twitter

    This is the first step for me to look at building an app that might send some tweets on my behalf, perhaps with the data stored somewhere, like, I don’t know, maybe a database?

  • Viewing Extended Properties for Information

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as#SQLNewBloggers.

    I’ve been working a little with extended properties, adding and updating them for various objects. However in addition to altering properties, viewing the properties on an object is often necessary. This post will look at how we get the properties in a few different ways.

    The easiest way to see extended properties is to look at the properties of an object in the SSMS Object Explorer. For example, I can right click on a table in OE.

    2015-11-02 20_30_55-

    Once I click Properties, I get a dialog with a lot of items on the left. The bottom one is for Extended Properties, with a simple add/edit/delete grid. Here I can see the property(ies) I’ve added.

    2015-11-02 20_31_07-Table Properties - SalesHeader_Staging

    However this is cumbersome for me. I’d much rather find a way to query the information, which is what I need to do with an application of some sort. I’d think sp_help would work, but it doesn’t. If I run this, I get the following result sets:

    • header with owner, type, and creation date.
    • column list with meta data
    • identity property information.
    • RowGuid column information
    • filegroup storage location.
    • Messages with index, constraint, FK, and schemabinding relations.

    Not very helpful in this case.

    I do know that extended property information is in sys.extended_properties. I can query this view, which gives me some information, but I need to join this with sys.objects for easy to understand information.

    2015-11-02 20_38_42-SQLQuery13.sql - aristotle.RaiseCodeQuality (ARISTOTLE_Steve (69))_ - Microsoft

    This works, and this is one of the ways in which I do query properties in various tSQLt tests.

    There is one other way I’ve seen to query extended properties. When perusing the BOL page for sp_updateextendedproperty, I found sys.fn_listextendedpropery. This is a DMF, a function, that you can use to query for property values. Since it’s a TVF function, I need to use it in a query as a functional object.

    2015-11-02 20_42_27-SQLQuery13.sql - aristotle.RaiseCodeQuality (ARISTOTLE_Steve (69))_ - Microsoft

    There are lots of parameters in this function. However you can guess what they are after working with the other extended property procedures. In fact, the first time I started this post, I was disconnected and had to experiment with the function, adding parameters until it ran without an error.

    The first parameter is the name of the property. This can be NULL, in which case you’ll get all the properties that exist.

    2015-11-02 20_44_48-SQLQuery13.sql - aristotle.RaiseCodeQuality (ARISTOTLE_Steve (69))_ - Microsoft

    The rest of the properties correspond to the level 0, 1, 2 types and names that you are using to filter the results. This is actually a good technique to use with this function, and I’ll be using this more in the future.

    SQLNewBlogger

    This post followed on from the previous ones. In this case, I started this disconnected, using the knowledge I had to write the basics with SSMS and the system table. That took about 20 minutes to document and then I spent 5 minutes experimenting with the function, whose name I had on an open browser tab. Once I worked through that, I spent another 5 minutes writing.

    Thirty minutes to a post. You can do this.

    Reference

    A few items from BOL:

    sp_help – https://msdn.microsoft.com/en-us/library/ms187335.aspx

    sys.extended_properties – https://msdn.microsoft.com/en-us/library/ms177541.aspx

    sys.fn_listextendedproperty – https://msdn.microsoft.com/en-us/library/ms179853.aspx

  • Back to SQL Saturday Washington DC

    I’ve been to the SQL Saturday in Washington, DC a few times and I’m looking forward to going back. It’s a good event and since I have family in the area, I can usually take a day or two of vacation and visit.

    This year the event is on Dec 5, 2015, and it’s SQL Saturday #470. Wow, we’re closing on #500, which is amazing.

    I’ve got two talks I’m giving, both of which I really like. I’ve revamped them both a little, incorporating a few new items in there and I hope everyone enjoys them.

    • Branding Yourself for a Dream Job
    • Get Testing with tSQLt

    The room I’m in will be the room for the day, with both myself and Brent Ozar giving two sessions around Wayne Sheffield talking T-SQL window functions. I know there are other great sessions, but feel free to camp out in this room.

    If you’re in the area, come join us for a free day of training. The event is in Chevy Chase at the Microsoft building.

  • Thankful in November

    I’m taking a short break from technical talk today to spend a few minutes thinking about life. My wife started the Thankfulness challenge in November, and while I didn’t participate, I’ve been thinking about life as I watch her posts.

    This is a career and learning blog, and much of my life has been about growing my career. However I’ve also had many things outside of my career that are important to me and occupy much of my time. My wife, my kids, my health and fitness, and various hobbies keep me busy, not to mention occasionally filling in as the ranch hand for my wife. I even got some unexpected, but very appreciated thanks this week.

    However there is something that I was amazed by this week. The outpouring of support for my call to make a #sqlwish come true was incredible. I was truly touched that so many people came together and donated money that allowed us to raise the entire amount in a day. Not even a day. This is one of those things that makes me think the SQL Server community, the #sqlfamily, is truly a special and amazing thing.

    Life is Hard

    I do struggle at times with the overall load. I struggle with stress at times. I have plenty of guilt when I’m away from home and something happens. I definitely find that I don’t always have the time I’d like for myself amid all the chaos in life.

    However I’m very lucky. I have a wonderful wife I love dearly. I have three kids, well two kids and an adult child, that are all healthy and successful in life. I have a good job that I enjoy. My family is financially secure. We don’t really have any complaints, and I definitely appreciate all that I have. I truly do try to stop and think about the amazing times I’ve had. I use Timehop to revisit memories in my life. I stop as I travel and reflect on the good and bad I see, while considering how I can leave the world a little better than what I found.

    I wrote about a fundraiser yesterday, trying to make a #sqlwish come true. I can’t imagine for a moment how my life would be different, or how much things would change if someone in my family were sick. I can’t really imagine the situation, and my heart goes out to Lucy and her family.

    As great as it’s been to make the wish come true, I also would like you to reflect a moment on the good things in your life. Your family, your health, your beliefs, the people around you, I’m sure there is some good around you. Stop for a minute and give thanks.

    I do hope that all of you reading this are well, and you are able to create a great career doing something you love. I will help where I can, and hopefully SQLServerCentral does that. However I know that life isn’t always easy or smooth. I hope that when you experience tough times that you have someone to help pull you through. If you really need an ear, the #sqlfamily is great. On Twitter, or in our wild and wacky thread, there are plenty willing to listen.