Jump to content

ameliabob

Members
  • Content Count

    213
  • Joined

  • Last visited

Community Reputation

3 Neutral

About ameliabob

  • Rank
    Member
  1. ameliabob

    Curl not returning values

    Just to close the loop and in case others are looking for the same solution. I put in the line "echo 'Curl error: '.curl_error($ch);" and found that the error was SSL Then since putting the url in the browser didn't ask for any user name and password I added the following line to the curl options curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); The false parameter says something to the effect 'don't care about verifying' and allows it to do its thing. and it works!! Thanks for getting me on the right path.
  2. ameliabob

    Curl not returning values

    OK, My error moving from Javascript to PHP. Fixed that and now get but still nothing back Array ( [url] => https://api.iextrading.com/1.0/stock/market/batch?types=quote&filter=symbol,latestPrice,&symbols=T,IBM [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 20 [redirect_count] => 0 [total_time] => 0.156 [namelookup_time] => 0.047 [connect_time] => 0.11 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => 35.224.167.123 [certinfo] => Array ( ) [primary_port] => 443 [local_ip] => 10.0.0.167 [local_port] => 53785 ) 1alertjresult is alertresult is putting the url into a browser gives the answer result as {"T":{"quote":{"symbol":"T","latestPrice":32.97}},"IBM":{"quote":{"symbol":"IBM","latestPrice":145.23}}} Now what is missing??
  3. ameliabob

    Curl not returning values

    I am trying to get to a site with the following code: $syms ="T,IBM"; $closeDict = array(); $url = "https://api.iextrading.com/1.0/stock/market/batch?types=quote&filter=symbol,latestPrice,&symbols="+$syms; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $jresult = curl_exec($ch); $info = curl_getinfo($ch); echo(print_r($info)); echo("alertjresult is ".$jresult); and several things are or are not happening. 1) the url doesn't get put into the header 2) There is no response Notice the alerts at the end. I seem to recall reading that there is an option to set when accessing a https site. However there is no password or other sign in function. If you cut and paste the url into a browser it operates just fine. What I have I overlooked?? [code}] Array ( => http://0/ [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 1.594 [namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 ) 1alertjresult is alertresult is [/code]
  4. ameliabob

    Resetting iterators

    I have the following code cur.execute("select symbol,stopPrice from holdings order by symbol" ) for row in cur: newSym =str(row[0]) if(syms==""): syms = newSym else: syms += ","+newSym holdingStops = BuildMyDict(cur) def BuildMyDict(response): myDict = dict() print(str(response)) for r in response: myDict[r[0]] = float(r[1]) return myDict When I get to the BuldMyDict it believes the cur has already completed. Is there a command that will reset the iterator counter?
  5. ameliabob

    Adding to dictionary

    I see many examples o dictionary used but I cannot find any that adds to an existing dictionary a = dict() a['fgh']=123 a['ghi'] = 345 Yields the error a['ghi']=345 TypeError: 'str' object does not support item assignment Is it only possible to build it once and not add to it??
  6. ameliabob

    calendar arithmetic

    I can see functions allowing the calculations of the difference between two dates but I cannot locate how to find the addition or subtraction of x number of days from a given date. Is there such a thing in python?
  7. ameliabob

    importng in python

    I have downloaded some routines that need to be "imported" into a python module. Where do I put them so that import finds them?
  8. ameliabob

    Dropping a table

    Actually I am executing this from within the sqlite "idle" shell
  9. ameliabob

    Dropping a table

    In all the examples they all seem to create a table before accessing it. How would I go about accessing one that has already been created the following code import sqlite3 conn = sqlite3.connect('earnings.db') cur = conn.cursor() DROP TABLE closed cur.execute('CREATE TABLE closed (rowId INTEGER PRIMARY KEY AUTOINCREMENT, nature TEXT) This generates a Syntax Error with TABLE highlighted in Red. If I remove the DROP line then I get the error that the table already exists ?????
  10. ameliabob

    sqlite startup

    I have been a user of SQL and am now trying to start up a private database using sqlite. There does not appear to be a corresponding tool like phpmyadmin that I can find. How can I display columns and contents. There is a reference to ./tables and ./columns. but I cannot find what these a part of. Are the usages the same whether I am using the python shell or the command line? That should get me started. Thanks
  11. ameliabob

    sqlite

    Is this where (gasp) I would ask questions on starting up with sqlite. I am trying to get a small project off the ground and find that some of the tutorials leave something to be desired as far as their examples are concerned. Or are other forums somewhere?
  12. ameliabob

    mysql and python

    The tutorial look simple and straight forward but when I run >>> import mysql.connector >>> mydb = mysql.connector.connect( host="localhost", user="root" ) I get this error Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mysql\connector\connection_cext.py", line 176, in _open_connection self._cmysql.connect(**cnx_kwargs) _mysql_connector.MySQLInterfaceError: Access denied for user 'root'@'localhost' (using password: NO) I never get to the cursor creation
  13. ameliabob

    mysql and python

    I am trying to install and start mysql under python. I am not sure that this is the correct forum or not. If not point me to the correct one. I am trying to run this query in the python environment but I am not sure what to import ahead of this code import mysql CREATE TABLE closed( rowId INT NOT NULL auto_INCREMENT type ENUM("O","S") symbol VARCHAR(6) sellDate DATE qty INT source VARCHAR(50) daysHeld INT pl INT ) ENGINE=InnoDB I keep getting the error "Invalid syntax" point to the word "TABLE" Thanx
  14. ameliabob

    converting string to Dict

    Thanks for the demo program. It gets me over the starting point.
  15. ameliabob

    converting string to Dict

    I am receiving a string and I can't see to get it into a dictionary.. For example I have a string: [{"rowId": 21,"nature": "O","symbol": "TAL","qty": 10,"daysHeld": 0,"source": "Momentum","dayEntered": "2018-01-16","pl": -40}, {"rowId": 22,"nature": "O","symbol": "SGMO","qty": 5,"daysHeld": 35,"source": "Lightning Trend","dayEntered": "2018-02-06","pl": 2300}, {"rowId": 23,"nature": "O","symbol": "NVDA","qty": 10,"daysHeld": 61,"source": "Tactical Trader","dayEntered": "2018-02-09","pl": -15300}, {"rowId": 24,"nature": "O","symbol": "ALGN","qty": 10,"daysHeld": 88,"source": "none","dayEntered": "2018-01-18","pl": -17100}, {"rowId": 25,"nature": "O","symbol": "IMGN","qty": 10,"daysHeld": 67,"source": "Lightning Trend","dayEntered": "2018-02-08","pl": 460}] How do I make this into a dict? How would I retreive the 'dayentered ' data from the line with symbol ALGN? Thanx
×