Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing dbf files from other programs
Message
 
To
19/06/2019 12:44:51
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01669166
Message ID:
01669198
Views:
70
>>>>Hi: I am both new to the idea of connecting VFP to other programs and flummoxed by it. I would like to be able to connect VFP to any of the following: postgreSQL, tableau or knime. I realize that ODBC or perhaps OLEDB should work; or, I could figure out how to write XLSX files that programs such as tableau and knime can presumably import. Which way should I proceed? Can some point me to a guide for using either ODBC or OLEDB. I have read every post I could find. I can see that others have figured out how to write to xlsx files. I would like to be able to prepare my tables in VFP because I have used it for so many years, I also wonder if OLEDB of ODBC can work when my installation of postgreSQL is 64 bits?
>>>>Thank you,
>>>>Steve
>>>
>>>In my 20+ years on the forums it is the first time I see that very common "flummoxed" word. Why would you target native speakers only :( - luckily my Mac OSX and safari have the ability for an easy word lookup without making hops.
>>>
>>>I would think in the context of postgreSQL and VFP:
>>>postgreSQL has FDWs. Unfortunately AFAIK, there is no OLEDB FDW or VFP FDW. There is ODBC. Using Sybase ADS in between ODBC FDW might be one solution.
>>>
>>>postgreSQL also can work with CSVs and xlsx (besides many other formats). But if you can export your data to such formats, then that means you can export to directly to postgreSQL or at worst to Sqlite (postgreSQL has SQLite FDW).
>>>
>>>It would be much better to know your exact scenario. It might be even more feasible to use postgreSQL extensions (writing code in other languages like Go, V8 Javascript, Python, C ...).
>>
>>And you are using a word that I am not familiar with, namely FMD. Thank you. I will take a look at Sybase and Sqlite. What do I need to do. Use VFP to write tables directly to the following: postgreSQL and tableau. Especially when getting into BI software, in so many cases, I find that it would be so much easier for me to alter tables as needed, rather than doing this is postreSQL or Tableau etc. So Tableau connects to both mySQL and postgreSQL, readily.
>>
>>I am asking for help here because I suspect that many of you have crossed this bridge years ago. I stayed with foxpro but now need to use other engines, as well.
>>Thanks, Steve
>
>I don't think I have used FMD, don't know what that is. Probably you meant FDW - Foreign Data Wrapper. PostgreSQL FDW is for linking directly to other backends.
>
>Writing directly to postgreSQL tables is as easy as 1,2,3 in VFP. Samples (this is just ODBC - SQL Pass Through sample, there is also (remote views and) CursorAdapter):
>
>
>Strcon = "Driver={PostgreSQL UNICODE};Server=127.0.0.1;Port=5432;Database=Northwind;Uid=postgres;Pwd=secret;"
>InsertSample()
>Sample1()
>Sample2()
>
>Procedure InsertSample
>	Local handle
>	handle = Sqlstringconnect( m.strCon )
>
>	Local customerId, companyName, lcSQL, ix
>	TEXT to m.lcSQL noshow
>	Insert into customers
>		(Customer_Id, Company_Name)
>	values
>		(?m.CustomerId, ?m.CompanyName)
>	ENDTEXT
>	For ix = 1 To 10
>		customerId = "XMP#"+Padl(m.ix,2,'0')
>		companyName = "My Company #"+Padl(m.ix,2,'0')
>		if SQLExec(m.handle, m.lcSQL) < 0
>			AError(aWhy)
>			MessageBox(aWhy[2],0+4096)
>			Exit
>		endif
>	Endfor
>	SQLDisconnect(m.handle)
>Endproc
>
>Procedure Sample1
>	Local handle
>	handle = Sqlstringconnect( m.strCon )
>	SQLExec(m.handle, "SELECT * FROM Customers", "resultCursor")
>	Select resultCursor
>	Browse
>	SQLDisconnect(m.handle)
>Endproc
>
>
>Procedure Sample2
>	Local lcSQL, handle
>	TEXT TO m.lcSQL NOSHOW TEXTMERGE
>SELECT *
>FROM Customers AS c
>WHERE c.Country = ?m.lcCountry;
>	ENDTEXT
>
>	handle = Sqlstringconnect( m.strCon )
>	SQLPrepare(m.handle, m.lcSQL, 'resultCursor')
>
>	Local Array laCountries[5]
>	laCountries[1] = 'USA'
>	laCountries[2] = 'UK'
>	laCountries[3] = 'Germany'
>	laCountries[4] = 'Argentina'
>	laCountries[5] = 'Mexico'
>
>	For ix = 1 To 5
>		lcCountry = laCountries[m.ix]
>		SQLExec(m.handle)
>		Select resultCursor
>		Browse
>	Endfor
>
>	SQLDisconnect(handle)
>Endproc
>
Cetin,
Does this require a 32 bit installation of postgres? Anyways, at the command line, I think I connected!
Strcon = "Driver={PostgreSQL UNICODE};Server=127.0.0.1;Port=5432;Database=myDatabase;Uid=postgres;Pwd=myPassword;"
handle = Sqlstringconnect( m.strCon )
?handle
1
While labels.dbf ships with foxpro, the following produces an error, and I am not sure why?
toCursor= SQLExec(m.handle, "SELECT * FROM labels", "resultCursor")
? toCursor
-1
Thanks,
Steve
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform